Skip to content
Advertisement

Determine if is a soft delete in a event handler Laravel

I have this event handler:

JavaScript

When I use $user->forceDelete(); and $user->delete(); this event is triggered and delete all comments. This is not ok because I want this event to be triggered only on $user->forceDelete();. In my case the other tables does not have soft delete implemented

Advertisement

Answer

You can check for the forceDeleting property on the model. This will be set (and true) if you’re performing a forceDelete

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement