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.
Architecture fit. The package targets a well-defined gap in Eloquent: application-level cascading for soft deletes, where database ON DELETE CASCADE cannot help because rows are only flagged, not removed. It integrates at the model layer via traits, which is idiomatic Laravel and requires no architectural change. That said, implicit cascade-on-delete is a domain rule living inside ORM lifecycle hooks; for a DDD-oriented or modular monolith it can obscure deletion semantics and make side effects hard to trace. Fit is strongest for conventional CRUD-style Laravel apps and weakest for systems with strict audit, retention, or regulatory deletion requirements.
Integration feasibility. Mechanically simple: composer require sofa/eloquent-cascade, add a trait, declare relations. The practical blocker is version compatibility. The last release (April 2021) predates Laravel 9/10/11, and Eloquent internals around SoftDeletes, model events, and forceDelete have shifted since. Expect a compatibility spike before any commitment.
Technical risk. Medium-to-high:
deleting/deleted.Key questions for engineering.
forceDelete, restore, and withTrashed relations?belongsToMany pivot rows, or only hasMany/hasOne/morphMany?Stack fit. Only relevant if we are on Laravel/Eloquent and specifically need soft-delete cascades. For pure hard deletes, native foreign keys with onDelete('cascade') are more reliable, faster, and database-enforced; this package should not be used as a substitute there.
Migration path. Treat it as a candidate, not a default. Run a time-boxed spike on a branch: install, add traits to one low-risk model graph, and write tests covering soft delete, force delete, restore, transaction rollback, and cyclic relations. If it fails on our Laravel version, the options are (a) fork and pin internally under MIT, (b) vendor the trait into our codebase, or (c) implement explicit cascade logic in a service/observer layer. Given the size of the package, forking or vendoring is low-cost and removes upstream risk.
Compatibility. Verify against:
composer.json constraints.Sequencing.
Maintenance. Assume we own it. Upstream is dormant; no security or compatibility patches should be expected. Budget for periodic review against Laravel upgrades. MIT licensing makes forking legally straightforward, which is the main mitigant.
Support. Community-only, thin community. No SLA, few Stack Overflow answers, and limited issue history. Internal documentation and tests become the real support surface. Ramp-up for a Laravel developer is low (a trait plus relation declarations), but understanding the failure modes is medium effort.
Scaling. Recursive application-level deletes scale worse than database cascades. Large graphs mean long-running transactions, row locks, replication lag, and potential timeouts. For high-volume or deep graphs, prefer asynchronous deletion jobs or database-level constraints where semantics allow. Soft-delete cascades also inflate table size and complicate purge jobs.
Failure modes.
Recommendation. Not a default dependency. Approve for low-risk, conventional CRUD graphs after a compatibility spike, with the code forked or vendored and covered by tests. For hard deletes, use database foreign keys. For critical or regulated data, implement explicit deletion in the service layer where the semantics are visible, testable, and auditable.
How can I help you explore Laravel packages today?