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

PersonalHomePage's avatar

how to handle soft deletes with daisy chained tables/models?

I can handle this with some logic in php, but I was wondering if there is something already built into Eloquent for this type of situation. I have 3 tables with a $this->hasMany type of relation. Lets say I want to delete something from table 2. Is there a feature in eloquent that lets you do a soft delete only if there's no fk referencing the entry in another table? For example User->Invoice->Order I would like to do a soft deletes on an invoice, but I need to make sure it has no orders attached to it. Also is there way to do cascade delete in eloquent (like a method) so I can delete an invoice with all of it's orders or a customer with all invoices and orders ?

0 likes
2 replies

Please or to participate in this conversation.