Best way to handle DeleteAction integrity constraint violations
Hi all
I've got a model with a restrictOnDelete relationship, so when I click the DeleteAction I get an integrity contraint violation.
I want to show a notification explaining why the record can't be deleted. What's the best way to handle this? Using the
before()
lifecycle hook? Or is there a better way?
Thanks5 Replies
Hi i have done it like this in one of the projects.
@ZedoX Do you know of a way to do it for a specific delete action rather than globally? I need to return a pretty detailed notification message for this one.
Solution
Yeah just use
->using()
on that delete actionAnd provide your custom deletion logic
@ZedoX Nice thanks