PHPackages                             fish/eloquent-cascade - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. fish/eloquent-cascade

ActiveLibrary[Database &amp; ORM](/categories/database)

fish/eloquent-cascade
=====================

Cascading delete trait for Laravel's Eloquent

1.3(9y ago)32.1k11MITPHPPHP &gt;=5.4.0

Since Jan 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/matfish2/eloquent-cascade)[ Packagist](https://packagist.org/packages/fish/eloquent-cascade)[ RSS](/packages/fish-eloquent-cascade/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (1)

Laravel Eloquent Cascading Delete
=================================

[](#laravel-eloquent-cascading-delete)

[![Latest Stable Version](https://camo.githubusercontent.com/87944359a79109fe049c14c72bfd90198e9e8c48d76f2620e313d4989e3c4568/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d636173636164652f762f737461626c65)](https://packagist.org/packages/fish/eloquent-cascade) [![Total Downloads](https://camo.githubusercontent.com/a74524741dadcb262c68837892daeb7853aeb90fef40b5d8c122bab4fa939c3f/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d636173636164652f646f776e6c6f616473)](https://packagist.org/packages/fish/eloquent-cascade) [![Latest Unstable Version](https://camo.githubusercontent.com/2099337bd47cae0f123d4b978946fdf289039a664f29901a5a57aeda4e5a8a10/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d636173636164652f762f756e737461626c65)](https://packagist.org/packages/fish/eloquent-cascade) [![License](https://camo.githubusercontent.com/3701ffaffcdc69f0fb0d76b031ec5ec5a0be6e1bbce9cc505984caca5a73b5ae/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d636173636164652f6c6963656e7365)](https://packagist.org/packages/fish/eloquent-cascade) [![Build Status](https://camo.githubusercontent.com/061e6cce7c211226970514a9af91e950750f632a281a225f065e07dbf52674dd/68747470733a2f2f7472617669732d63692e6f72672f6d617466697368322f656c6f7175656e742d636173636164652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/matfish2/eloquent-cascade)

This package offers a simple trait that leverages the Eloquent delete event to recursively delete all specified relations for a given model.

Installation
------------

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `fish/eloquent-cascade`.

```
"require": {
  "fish/eloquent-cascade": "^1.0"
}

```

Next, update Composer from the Terminal:

```
composer update

```

Usage
-----

[](#usage)

1. Include the trait in a parent model and make the other models extend it:

    ```
     namespace App;

     use Illuminate\Database\Eloquent\Model;
     use Fish\Cascade\Cascade;

     class BaseModel extends Model
     {
         use Cascade;
     }

    ```
2. Add the relations you wish to delete to a protected `$cascade` array on the model. e.g:

    ```
     class User extends BaseModel
     {

         protected $cascade = ['author'];

         public function author() {

           return $this->hasOne(Author::class);

         }
     }

     class Author extends BaseModel
     {

         protected $cascade = ['posts'];

         public function user() {

           return $this->belongsTo(User::class);

         }

         public function posts() {

           return $this->hasMany(Post::class);

         }

     }

     class Post extends BaseModel
     {

       protected $cascade = ['comments'];

       public function comments() {

         return $this->hasMany(Comment::class);

       }

     }

    ```

If you are using a trait for polymorphic relations and want to add this relation to the `$cascade` array, override the protected `getCascade` method. Suppose you have a `Locale` trait:

```
   trait Locale {

    public function locale() {
        return $this->morphMany(Locale::class, 'translatable');
    }

    protected function getCascade() {
      return array_merge($this->cascade, ['locale']);
    }

   }

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Total

4

Last Release

3559d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef7c699ed71e1fdeb389a1aba23f26d02a0a9b7554dd9b8375b739c0357f7339?d=identicon)[matfish2](/maintainers/matfish2)

---

Top Contributors

[![matfish2](https://avatars.githubusercontent.com/u/1510460?v=4)](https://github.com/matfish2 "matfish2 (20 commits)")

---

Tags

laraveleloquentrelationsdeletecascade

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fish-eloquent-cascade/health.svg)

```
[![Health](https://phpackages.com/badges/fish-eloquent-cascade/health.svg)](https://phpackages.com/packages/fish-eloquent-cascade)
```

###  Alternatives

[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[shiftonelabs/laravel-cascade-deletes

Adds application level cascading deletes to Eloquent Models.

163632.1k2](/packages/shiftonelabs-laravel-cascade-deletes)[cesargb/laravel-cascade-delete

Cascading eliminations implemented in polymorphic relationships for the Laravel apps

1956.1k1](/packages/cesargb-laravel-cascade-delete)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[korridor/laravel-has-many-sync

Laravel has many sync

3578.1k](/packages/korridor-laravel-has-many-sync)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
