File: /home/xedaptot/ai.naniguide.com/app/Http/Controllers/Refactor/BrandVoiceController.php
<?php
namespace App\Http\Controllers\Refactor;
use App\Http\Controllers\Controller;
use App\Http\Requests\Refactor\UpdateBrandVoiceRequest;
use App\Model\BrandVoice;
use Illuminate\Http\Request;
/**
* Brand voice settings for the authenticated user.
*
* Consumed by `BrandVoiceContextProvider` (tier 4) when the inline
* rewrite popover runs an action for which brand voice is relevant
* (improve / cta_ify / rewrite / rewrite_on_brand). Per AI_FEATURES_PLAN
* §12 Q10 — shipped as a side quest in F1.0.
*/
class BrandVoiceController extends Controller
{
public function edit(Request $request)
{
$user = $request->user();
$voice = $user->brandVoice;
return view('refactor.pages.account.brand_voice', [
'voice' => $voice,
'adjectives' => $voice && is_array($voice->adjectives) ? $voice->adjectives : [],
'forbidden' => $voice && is_array($voice->forbidden) ? $voice->forbidden : [],
'sample' => $voice ? (string) $voice->sample : '',
'menu' => 'brand_voice',
]);
}
public function update(UpdateBrandVoiceRequest $request)
{
$user = $request->user();
$adjectives = $request->adjectivesList();
$forbidden = $request->forbiddenList();
$sample = $request->sampleText();
$voice = $user->brandVoice ?? new BrandVoice(['user_id' => $user->id]);
$voice->user_id = $user->id;
$voice->adjectives = $adjectives;
$voice->forbidden = $forbidden;
$voice->sample = $sample;
$voice->save();
$request->session()->flash(
'alert-success',
trans('refactor/ai_rewrite.brand_voice.flash_saved')
);
return redirect()->route('refactor.account.brand_voice');
}
}