trypost/app/Http/Requests/App/Workspace/UpdateWorkspaceRequest.php
Paulo Castellano b7773849ec Save the autofilled site logo as the workspace logo on brand settings update
Brand autofill on the workspace settings page already captured the site logo
and rendered a preview beneath the URL, but the update flow never persisted it.
The store flow attached it via LogoAttacher; the update flow was missing all
three legs: the form field, the request rule, and the controller attach.

- BrandTab: add logo_url to the useForm payload so autofill can set it and the
  form submits it.
- UpdateWorkspaceRequest: validate logo_url (nullable url) — FormRequest strips
  any unvalidated key, so without a rule it was silently dropped.
- WorkspaceController::updateSettings: pull logo_url out of the validated data
  (it is not a column) and attach it through LogoAttacher, mirroring store.
2026-07-03 20:05:54 -03:00

48 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\App\Workspace;
use App\Enums\Workspace\BrandFont;
use App\Enums\Workspace\BrandVoiceTrait;
use App\Enums\Workspace\ContentLanguage;
use App\Enums\Workspace\ImageStyle;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateWorkspaceRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$hex = ['nullable', 'string', 'regex:/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/'];
return [
'name' => ['required', 'string', 'max:255'],
'brand_website' => ['nullable', 'url', 'max:255'],
'brand_description' => ['nullable', 'string', 'max:2000'],
'brand_voice_traits' => ['nullable', 'array'],
'brand_voice_traits.*' => ['string', Rule::enum(BrandVoiceTrait::class)],
'brand_color' => $hex,
'background_color' => $hex,
'text_color' => $hex,
'brand_font' => ['sometimes', 'required', 'string', Rule::in(BrandFont::values())],
'image_style' => ['sometimes', 'required', 'string', Rule::in(ImageStyle::values())],
'content_language' => ['sometimes', 'string', Rule::in(ContentLanguage::values())],
'logo_url' => ['nullable', 'url', 'max:1024'],
];
}
public function messages(): array
{
return [
'name.required' => 'The workspace name is required.',
'name.max' => 'The workspace name must be at most 255 characters.',
];
}
}