sofa/eloquent-cascade
Sofa/eloquent-cascade adds cascading delete and update behavior to Laravel Eloquent models, letting you propagate changes through related records automatically. Configure cascades on relationships to keep parent and child data consistent without manual cleanup code.
ON DELETE CASCADE foreign keys, (b) hand-rolled model observers/events, or (c) a small package. Since soft deletes cannot be expressed as a database constraint, any product with SoftDeletes plus parent-child data has to solve this in application code — this package is a pre-built answer to that narrow question.Adopt (or, more likely, read and vendor) it when:
SoftDeletes and you need cascade behavior across hasMany/morphMany relations, where database foreign keys cannot help.Look elsewhere — or write it yourself — when:
ON DELETE CASCADE plus explicit soft-delete handling in a queued job — cascading deletes executed row-by-row in PHP can be slow and can partially fail on large trees.composer.json.To executives: This is not a strategic dependency — it's a small, MIT-licensed utility that saves roughly one to two engineering days on "what gets deleted when we delete an account" logic, a question every product with soft deletes eventually faces. It has negligible community traction and hasn't been released since 2021, so I'd recommend treating it as a code sample we adapt and own rather than a long-term vendor dependency. Either way, the outcome is faster delivery of correct, reversible delete behavior and a documented retention policy.
To engineering: It's a trait that declaratively cascades soft and hard deletes across Eloquent relations, covering the gap where SQL foreign keys can't reach soft-deleted rows. Low coupling, easy to vendor. Two caveats before we commit: confirm compatibility with our Laravel version (no release in ~4 years), and avoid using it for deep relation trees or high-volume deletes where per-row PHP cascades will be slow — there we should prefer queued jobs or database constraints. Recommendation: one-day spike, then either vendor the trait with our own tests or write equivalent observers in-house.
How can I help you explore Laravel packages today?