1414use Filament \Tables \Table ;
1515use Illuminate \Support \Facades \Hash ;
1616use Illuminate \Validation \Rules \Password ;
17+ use Vormkracht10 \Fields \Filament \RelationManagers \FieldsRelationManager ;
1718
1819class UserResource extends Resource
1920{
@@ -27,27 +28,33 @@ public static function getModel(): string
2728 public static function form (Form $ form ): Form
2829 {
2930 return $ form
30- ->schema ([
31- Forms \Components \TextInput::make ('name ' )
32- ->label (__ ('Name ' ))
33- ->required ()
34- ->maxLength (255 ),
35- Forms \Components \TextInput::make ('email ' )
36- ->label (__ ('Email ' ))
37- ->email ()
38- ->required ()
39- ->maxLength (255 ),
40-
41- Forms \Components \TextInput::make ('password ' )
42- ->password ()
43- ->label (__ ('Password ' ))
44- ->revealable (Filament::arePasswordsRevealable ())
45- ->rule (Password::default ())
46- ->autocomplete ('new-password ' )
47- ->dehydrated (fn ($ state ): bool => filled ($ state ))
48- ->dehydrateStateUsing (fn ($ state ): string => Hash::make ($ state ))
49- ->live (debounce: 500 ),
50- ]);
31+ ->schema (function ($ livewire ) {
32+ $ livewire = $ livewire ;
33+
34+ $ formFields = $ livewire ->getFormFields ();
35+
36+ return array_merge ([
37+ Forms \Components \TextInput::make ('name ' )
38+ ->label (__ ('Name ' ))
39+ ->required ()
40+ ->maxLength (255 ),
41+ Forms \Components \TextInput::make ('email ' )
42+ ->label (__ ('Email ' ))
43+ ->email ()
44+ ->required ()
45+ ->maxLength (255 ),
46+
47+ Forms \Components \TextInput::make ('password ' )
48+ ->password ()
49+ ->label (__ ('Password ' ))
50+ ->revealable (Filament::arePasswordsRevealable ())
51+ ->rule (Password::default ())
52+ ->autocomplete ('new-password ' )
53+ ->dehydrated (fn ($ state ): bool => filled ($ state ))
54+ ->dehydrateStateUsing (fn ($ state ): string => Hash::make ($ state ))
55+ ->live (debounce: 500 ),
56+ ], $ formFields );
57+ });
5158 }
5259
5360 public static function table (Table $ table ): Table
@@ -95,7 +102,7 @@ public static function table(Table $table): Table
95102 public static function getRelations (): array
96103 {
97104 return [
98- //
105+ FieldsRelationManager::class
99106 ];
100107 }
101108
0 commit comments