File tree Expand file tree Collapse file tree 4 files changed +38
-3
lines changed
Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,36 @@ public static function table(Table $table): Table
115115 ])
116116 ->bulkActions ([
117117 Tables \Actions \DeleteBulkAction::make (),
118+ Tables \Actions \BulkAction::make ('delete_banned ' )
119+ ->label (__ ('Supprimer les utilisateurs bannis ' ))
120+ ->icon ('heroicon-o-trash ' )
121+ ->color ('danger ' )
122+ ->action (function ($ records ): void {
123+
124+ $ bannedUsers = $ records ->whereNotNull ('banned_at ' );
125+
126+ if ($ bannedUsers ->isEmpty ()) {
127+ Notification::make ()
128+ ->warning ()
129+ ->title (__ ('actions.delete_none ' ))
130+ ->body (__ ('actions.delete_none_description ' ))
131+ ->send ();
132+
133+ return ;
134+ }
135+
136+ $ bannedUsers ->each (function (User $ user ): void {
137+ $ user ->delete ();
138+ });
139+
140+ Notification::make ()
141+ ->success ()
142+ ->title (__ ('actions.delete_success ' ))
143+ ->body (__ ('actions.delete_success_description ' ))
144+ ->send ();
145+ })
146+ ->requiresConfirmation ()
147+ ->deselectRecordsAfterCompletion (),
118148 ]);
119149 }
120150
Original file line number Diff line number Diff line change @@ -18,8 +18,6 @@ public function getTabs(): array
1818 'all ' => Tab::make (__ ('global.all ' )),
1919 'banned ' => Tab::make (__ ('global.banned ' ))
2020 ->modifyQueryUsing (fn ($ query ) => $ query ->isBanned ()),
21- 'unbanned ' => Tab::make (__ ('global.unbanned ' ))
22- ->modifyQueryUsing (fn ($ query ) => $ query ->isNotBanned ()),
2321 ];
2422 }
2523}
Original file line number Diff line number Diff line change 1515 'confirm ' => 'Confirm ' ,
1616 'start ' => 'Start ' ,
1717 'view ' => 'View ' ,
18-
18+ 'delete_none ' => 'No users to delete ' ,
19+ 'delete_none_description ' => 'No banned users were found in the selection. ' ,
20+ 'delete_success ' => 'Users successfully deleted. ' ,
21+ 'delete_success_description ' => 'Only banned users have been deleted. ' ,
1922];
Original file line number Diff line number Diff line change 1515 'confirm ' => 'Confirmer ' ,
1616 'start ' => 'Démarrer ' ,
1717 'view ' => 'Voir ' ,
18+ 'delete_none ' => 'Aucun utilisateur à supprimer ' ,
19+ 'delete_none_description ' => 'Aucun utilisateur banni n \'a été trouvé dans la sélection ' ,
20+ 'delete_success ' => 'Suppression effectuée ' ,
21+ 'delete_success_description ' => 'Seuls les utilisateurs bannis ont été supprimés. ' ,
1822];
You can’t perform that action at this time.
0 commit comments