there are few packages that allow you to do it - but if you want to do it yourself, you have to use EVENT/Observables... so hook into a Models Deleting/Deleted Event and delete the child record yourself and if necessary hook into that one to cascade down..
Oct 6, 2018
1
Level 2
Foreign keys + soft deletes?
I'm wanting to set up a cascading delete, which is supported and great: https://laravel.com/docs/5.7/migrations#foreign-key-constraints
However, I don't see any mention of how to handle this with soft deletes. In my case, I want to soft-delete a show model but enforce a foreign key constraint and delete everything that references that show. I don't exactly expect a Laravel solution to this since the show is still in the database and thus there technically isn't anything to delete. I can handle it manually, just curious if there is a more elegant solution out there. Thanks!
Level 23
1 like
Please or to participate in this conversation.