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 CeeOP5mo 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_10270
lukasinko_102704mo ago
I'm curious about this too.
lukasinko_10270
lukasinko_102704mo 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();
}
}

Did you find this page helpful?