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(), ]); } }