Soft Deleting through relationships
<p>I am trying to understand something.  </p>

<p>I have a Project Model.<br>
A Project can have many Document.<br>
A Document has many DocumentData.</p>

<p>So this is straight forward, I have my models set up like so</p>

<pre><code>class Project extends Model
{
    protected $table = 'projects';
    protected $guarded = [];
    use SoftDeletes;

    public function document()
    {
        return $this-&gt;hasMany('App\document', 'projectId');
    }

    public static function boot()
    {
        parent::boot();

        static::deleted(function($document)
        {
            $document-&gt;delete();
        });
    }
}

class Document extends Model
{
    use SoftDeletes;

    protected $table = 'document';
    protected $guarded = [];

    public function project()
    {
        return $this-&gt;belongsTo('App\Project', 'projectId');
    }

    public function documentData()
    {
        return $this-&gt;hasMany('App\DocumentData', 'documentId');
    }

    public static function boot()
    {
        parent::boot();

        static::deleted(function($document)
        {
            $document-&gt;documentData()-&gt;delete();
        });
    }
}

class DocumentData extends Model
{
    use SoftDeletes;

    protected $table = 'document_data';
    protected $guarded = [];

    public function document()
    {
        return $this-&gt;belongsTo('App\Document', 'documentId');
    }
}
</code></pre>

<p>I am trying to understand the boot function and whether I have set it up properly?  When I delete a project, its deleted_at timestamp is set.  I am also looking for it to set the deleted at timestamp for all of that Projects Documents and DocumentData.  </p>

<p>At the moment, when I delete a Project, on its deleted_at timestamp is set.  The Document and DocumentData remains null.</p>

<p>How can I get it soft deleting through all related models?</p>

<p>Thanks</p>