feat: locale
This commit is contained in:
@@ -35,6 +35,11 @@ class UserForm
|
||||
->required()
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(255),
|
||||
Select::make('locale')
|
||||
->label(__('admin.users.fields.locale'))
|
||||
->options(self::localeOptions())
|
||||
->default('en')
|
||||
->required(),
|
||||
FileUpload::make('avatar_url')
|
||||
->label(__('admin.users.fields.avatar'))
|
||||
->image()
|
||||
@@ -136,4 +141,18 @@ class UserForm
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private static function localeOptions(): array
|
||||
{
|
||||
$labels = __('admin.users.locales');
|
||||
|
||||
return collect(config('app.supported_locales', ['fr', 'en']))
|
||||
->mapWithKeys(fn (string $locale): array => [
|
||||
$locale => is_array($labels) ? ($labels[$locale] ?? $locale) : $locale,
|
||||
])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user