evanr
evanr

Reputation: 4616

Trying to add notifications to a crud operation in list view

I'm trying to add some notifications to the delete operation on one of my cruds, basically to inform the admin that while successful, the model has some lingering relationships that they may want to remove/deal with.

I've tried adding \Alert::add('warning', 'The text of the notification')->flash(); into the delete operation (and this does show up if the page is then refreshed) but isn't shown in the same way the "Item deleted successfully" one is.

The only option I can see is to not use $this->crud->delete($id); and build out all the functionality there on my own.

Upvotes: 0

Views: 645

Answers (1)

user14339690
user14339690

Reputation:

I also had a similar situation to you. What I did is, First I have written my condition in destroy function I have created if and in else conditions in if my conditional logic and in else "$this->crud->delete($id)". In my code, if the condition is not met then I have simply return a boolean('true|false') in the form of a string and catch that as result in "resources/views/vendor/backpack/crud/buttons/delete.blade.php" and make your custom notification in if condition.

Upvotes: 1

Related Questions