33namespace Backstage \Filament \Users \Resources \UserResource \Schemas ;
44
55use BackedEnum ;
6+ use Backstage \Filament \Users \Resources \RoleResource \RoleResource ;
67use Filament \Forms \Components \DateTimePicker ;
8+ use Filament \Forms \Components \Select ;
79use Filament \Forms \Components \TextInput ;
10+ use Filament \Pages \Page ;
811use Filament \Resources \Pages \CreateRecord ;
912use Filament \Schemas \Components \Fieldset ;
1013use Filament \Schemas \Components \Grid ;
@@ -33,14 +36,29 @@ public static function configure(Schema $schema): Schema
3336
3437 TextInput::make ('email ' )
3538 ->label (__ ('Email ' ))
36- ->prefixIcon (fn (): BackedEnum => Heroicon::Envelope, true )
39+ ->prefixIcon (fn (): BackedEnum => Heroicon::Envelope, true )
3740 ->email ()
3841 ->required (),
3942
43+ Select::make ('roles ' )
44+ ->label (__ ('Roles ' ))
45+ ->visible (fn (Page $ livewire ): bool => $ livewire instanceof CreateRecord)
46+ ->relationship (titleAttribute: fn (): string => 'name ' )
47+ ->prefixIcon (fn (): BackedEnum => RoleResource::getActiveNavigationIcon (), true )
48+ ->prefixIconColor (fn (): string => 'primary ' )
49+ ->preload ()
50+ ->multiple ()
51+ ->required ()
52+ ->loadingMessage (fn (): string => __ ('Loading roles... ' ))
53+ ->maxItemsMessage (fn (Select $ component ): string => __ ('You can select up to :count roles. ' , ['count ' => $ component ->getMaxItems ()]))
54+ ->searchingMessage (fn (): string => __ ('Searching roles... ' ))
55+ ->placeholder (fn (): string => __ ('Select roles ' ))
56+ ->native (fn (): bool => false ),
57+
4058 TextInput::make ('password ' )
4159 ->password ()
42- ->hidden (fn (TextInput $ component ): bool => $ component ->getLivewire () instanceof CreateRecord)
43- ->prefixIcon (fn (): BackedEnum => Heroicon::LockClosed, true )
60+ ->hidden (fn (TextInput $ component ): bool => $ component ->getLivewire () instanceof CreateRecord)
61+ ->prefixIcon (fn (): BackedEnum => Heroicon::LockClosed, true )
4462 ->revealable (),
4563 ])
4664 ->columns (2 )
@@ -49,7 +67,7 @@ public static function configure(Schema $schema): Schema
4967 ->columnSpan (6 ),
5068
5169 Fieldset::make ()
52- ->hidden (fn (Fieldset $ component ): bool => $ component ->getLivewire () instanceof CreateRecord)
70+ ->hidden (fn (Fieldset $ component ): bool => $ component ->getLivewire () instanceof CreateRecord)
5371 ->schema ([
5472 Section::make (__ ('Email verification ' ))
5573 ->description (__ ('Email verification is required for users. ' ))
@@ -58,8 +76,8 @@ public static function configure(Schema $schema): Schema
5876 DateTimePicker::make ('email_verified_at ' )
5977 ->label (__ ('Email Verified ' ))
6078 ->live ()
61- ->prefixIcon (fn (DateTimePicker $ component ): BackedEnum => ! $ component ->getState () ? Heroicon::XCircle : Heroicon::CheckCircle, true )
62- ->prefixIconColor (fn (DateTimePicker $ component ): string => ! $ component ->getState () ? 'danger ' : 'success ' ),
79+ ->prefixIcon (fn (DateTimePicker $ component ): BackedEnum => ! $ component ->getState () ? Heroicon::XCircle : Heroicon::CheckCircle, true )
80+ ->prefixIconColor (fn (DateTimePicker $ component ): string => ! $ component ->getState () ? 'danger ' : 'success ' ),
6381 ])
6482 ->columns (1 )
6583 ->columnSpanFull (),
0 commit comments