schema([ Section::make()->schema([ TextInput::make('username') ->required() ->minLength(3) ->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)) ->password(), Select::make('language') ->required() ->hidden() ->default('en') ->options(fn (LanguageService $languageService) => $languageService->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(['default' => 1, 'lg' => 3]), ]); } 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 []; } }