deleteAny policy - prevent self deletion

When using the deleteAny policy to allow bulk deletion, how can I modify to prevent allowing the ability to bulk delete myself from the list
4 Replies
Jamie Cee
Jamie CeeOP3mo ago
For some reason I cant see the body of this ticket.... when using the deleteAny function for bulk delete, how can I prevent allowing the user to be able to delete themselves from that list
lukasinko
lukasinko2mo ago
I'm curious about this too.
lukasinko
lukasinko2mo ago
I've found one can probably also do something like in UserResource
Tables\Actions\DeleteBulkAction::make()
->before(function (Tables\Actions\DeleteBulkAction $action, Collection $records) {
if($records->filter(fn($record) => $record->id === auth()->user()->id)->count() !== 0){
//optionally show some notification
$action->halt();
}
}
Tables\Actions\DeleteBulkAction::make()
->before(function (Tables\Actions\DeleteBulkAction $action, Collection $records) {
if($records->filter(fn($record) => $record->id === auth()->user()->id)->count() !== 0){
//optionally show some notification
$action->halt();
}
}
Want results from more Discord servers?
Add your server