@@ -19,13 +19,7 @@ class UserResource extends Resource
1919{
2020 protected static ?string $ model = User::class;
2121
22- protected static ?string $ navigationGroup = 'System ' ;
23-
24- protected static ?string $ navigationIcon = 'heroicon-o-rectangle-stack ' ;
25-
26- protected static ?int $ navigationSort = 0 ;
27-
28- protected static ?string $ slug = 'system/users ' ;
22+ protected static ?string $ navigationIcon = 'heroicon-o-users ' ;
2923
3024 public static function form (Form $ form ): Form
3125 {
@@ -65,20 +59,48 @@ public static function form(Form $form): Form
6559 ->visible (fn ($ livewire ) => $ livewire instanceof EditUser)
6660 ->dehydrated (false ),
6761 ])
68- ->columns (' full ' )
62+ ->columns (1 )
6963 ->columnSpan ([
7064 'md ' => 2 ,
7165 ]),
7266
73- Forms \Components \Section::make ()
67+ Forms \Components \Grid::make ([
68+ 'default ' => 1 ,
69+ ])
7470 ->schema ([
75- Forms \Components \Placeholder::make ('created_at ' )
76- ->content (fn ($ record ) => $ record ?->created_at?->diffForHumans() ?? new HtmlString ('— ' )),
77- Forms \Components \Placeholder::make ('updated_at ' )
78- ->content (fn ($ record ) => $ record ?->updated_at?->diffForHumans() ?? new HtmlString ('— ' )),
71+ Forms \Components \Section::make ()
72+ ->schema ([
73+ Forms \Components \Select::make ('role ' )
74+ ->options ([
75+ 'admin ' => 'Admin ' ,
76+ 'guest ' => 'Guest ' ,
77+ 'user ' => 'User ' ,
78+ ])
79+ ->default ('guest ' )
80+ ->disabled (fn (): bool => ! auth ()->user ()->is_admin || auth ()->user ()->is_user )
81+ ->required (),
82+ ])
83+ ->columns (1 )
84+ ->columnSpan ([
85+ 'md ' => 1 ,
86+ ]),
87+
88+ Forms \Components \Section::make ()
89+ ->schema ([
90+ Forms \Components \Placeholder::make ('created_at ' )
91+ ->content (fn ($ record ) => $ record ?->created_at?->diffForHumans() ?? new HtmlString ('— ' )),
92+ Forms \Components \Placeholder::make ('updated_at ' )
93+ ->content (fn ($ record ) => $ record ?->updated_at?->diffForHumans() ?? new HtmlString ('— ' )),
94+ ])
95+ ->columns (1 )
96+ ->columnSpan ([
97+ 'md ' => 1 ,
98+ ]),
7999 ])
80- ->columns ('full ' )
81- ->columnSpan (1 ),
100+ ->columns (1 )
101+ ->columnSpan ([
102+ 'md ' => 1 ,
103+ ]),
82104 ]),
83105 ]);
84106 }
@@ -87,27 +109,36 @@ public static function table(Table $table): Table
87109 {
88110 return $ table
89111 ->columns ([
112+ Tables \Columns \TextColumn::make ('id ' )
113+ ->label ('ID ' ),
90114 Tables \Columns \TextColumn::make ('name ' )
91115 ->searchable (),
92116 Tables \Columns \TextColumn::make ('email ' )
93117 ->searchable (),
94- Tables \Columns \TextColumn::make ('email_verified_at ' )
95- ->dateTime (),
96- Tables \Columns \TextColumn::make ('created_at ' )
97- ->dateTime (),
118+ Tables \Columns \TextColumn::make ('role ' )
119+ ->badge ()
120+ ->color (fn (string $ state ): string => match ($ state ) {
121+ 'admin ' => 'success ' ,
122+ 'guest ' => 'gray ' ,
123+ 'user ' => 'info ' ,
124+ }),
98125 Tables \Columns \TextColumn::make ('updated_at ' )
126+ ->label ('Last updated ' )
99127 ->dateTime (),
100128 ])
101129 ->filters ([
102- //
130+ Tables \Filters \SelectFilter::make ('role ' )
131+ ->options ([
132+ 'admin ' => 'Admin ' ,
133+ 'guest ' => 'Guest ' ,
134+ 'user ' => 'User ' ,
135+ ]),
103136 ])
104137 ->actions ([
105- Tables \Actions \EditAction::make (),
106- ])
107- ->bulkActions ([
108- Tables \Actions \BulkActionGroup::make ([
109- Tables \Actions \DeleteBulkAction::make ()
110- ->requiresConfirmation (),
138+ Tables \Actions \ActionGroup::make ([
139+ Tables \Actions \ViewAction::make (),
140+ Tables \Actions \EditAction::make (),
141+ Tables \Actions \DeleteAction::make (),
111142 ]),
112143 ]);
113144 }
0 commit comments