Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mhetreramesh's avatar

How to customize delete functionality on nova?

Before deleting a row from nova I wants to do custom check. If check fails don't delete if check pass then delete.

I'm trying overriding delete method on model to do extra check, which I think works fine but how can I throw nova toast error message to customer for delete functionality?

0 likes
5 replies
m7vm7v's avatar

You could define a new Action.

php artisan nova:action DeleteModel so then in the handle method you could add the delete action

public function handle(ActionFields $fields, Collection $models)
{
    foreach($models as $model){
        //Your custom logic before delete
        $model->delete(); //->softDelete()

        //if the deletion fails then return a Action::danger('Message');
    }

    return Action::message('Deleted!');
}

In the nova Model add the new DeleteModel action in the actions() method.

Do not forget to remove the delete button from the default actions.

so then if you need for this action some additional information you could add this in the fields() method in the DeleteModel.

Have a look at this video - https://laracasts.com/series/laravel-nova-mastery/episodes/10

webinarincadmin's avatar

You can overiide the delete function in your model.. by creating a function

public function delete() {
   // codes here
}
2 likes
bhavin-zwt's avatar

How can we set delete message in the index (list) page?

2 likes

Please or to participate in this conversation.