The new content-language options were hand-duplicated across request validation, the UI picker, and homepage detection, while the brand analyzer's structured-output enum and the AI image prompt's language name still only knew about en/pt-BR/es. That left autofill unable to detect the new languages and made image text fall back to English for them. Introduce App\Enums\Workspace\ContentLanguage as the single source of truth and derive every site from it: - Store/UpdateWorkspaceRequest validate against ContentLanguage::values() - BrandAnalyzer's language enum uses ContentLanguage::values() - AiImageClient::languageName() resolves via the enum's englishName() - HomepageMetaExtractor detects through ContentLanguage::fromHtmlLang() - BrandForm consumes availableContentLanguages from the backend, like availableFonts/availableImageStyles, instead of a hardcoded list Also fix two labels: nl "Nederlandse" -> "Nederlands", zh -> "中文".
48 lines
1.6 KiB
PHP
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 StoreWorkspaceRequest 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', 'string', Rule::in(BrandFont::values())],
|
|
'image_style' => ['sometimes', 'string', Rule::in(ImageStyle::values())],
|
|
'content_language' => ['nullable', 'string', Rule::in(ContentLanguage::values())],
|
|
'logo_url' => ['nullable', 'url', 'max:1024'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'name.required' => 'O nome do workspace é obrigatório.',
|
|
'name.max' => 'O nome do workspace deve ter no máximo 255 caracteres.',
|
|
];
|
|
}
|
|
}
|