Files
hr/app/Filament/Resources/Users/Schemas/UserForm.php
2026-07-31 18:08:08 +05:00

54 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Resources\Users\Schemas;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
use Illuminate\Support\Facades\Hash;
class UserForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required()
->maxLength(255),
TextInput::make('email')
->label(__('hr.fields.email_address'))
->email()
->required()
->maxLength(255)
->unique(ignoreRecord: true),
TextInput::make('password')
->password()
->dehydrateStateUsing(fn (?string $state): ?string => filled($state) ? Hash::make($state) : null)
->dehydrated(fn (?string $state): bool => filled($state))
->required(fn (string $operation): bool => $operation === 'create')
->maxLength(255),
Select::make('department_id')
->relationship('department', 'name')
->searchable()
->preload()
->label(__('hr.fields.department_for_managers')),
Select::make('locale')
->label(__('hr.fields.locale'))
->options(collect(config('hr.supported_locales'))
->mapWithKeys(fn (string $locale): array => [$locale => config('hr.locale_labels')[$locale]])
->all())
->required()
->default(config('hr.default_locale')),
Select::make('roles')
->relationship('roles', 'name')
->multiple()
->preload()
->searchable()
->required(),
]);
}
}