schema([ Section::make()->schema([ TextInput::make('username')->required()->maxLength(255), TextInput::make('email')->email()->required()->maxLength(255), TextInput::make('password') ->dehydrateStateUsing(fn (string $state): string => Hash::make($state)) ->dehydrated(fn (?string $state): bool => filled($state)) ->required(fn (string $operation): bool => $operation === 'create') ->password(), Select::make('language') ->required() ->hidden() ->default('en') ->options(fn (User $user) => $user->getAvailableLanguages()), Hidden::make('skipValidation')->default(true), CheckboxList::make('roles') ->disabled(fn (User $user) => $user->id === auth()->user()->id) ->disableOptionWhen(fn (string $value): bool => $value == Role::getRootAdmin()->id) ->relationship('roles', 'name') ->label('Admin Roles') ->columnSpanFull() ->bulkToggleable(false), ])->columns(), ]); } protected function getHeaderActions(): array { return [ DeleteAction::make() ->label(fn (User $user) => auth()->user()->id === $user->id ? 'Can\'t Delete Yourself' : ($user->servers()->count() > 0 ? 'User Has Servers' : 'Delete')) ->disabled(fn (User $user) => auth()->user()->id === $user->id || $user->servers()->count() > 0), $this->getSaveFormAction()->formId('form'), ]; } protected function getFormActions(): array { return []; } }