Skip to content

Commit

Permalink
[Gutenbergable] Delete lb_content when parent model is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricewijnia committed May 21, 2019
1 parent 838f811 commit f06517a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Models/Gutenbergable.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ private function createContent()
$this->content = $content;
event(new ContentCreated($content));
}

/**
* Delete content when model gets deleted
*/
protected static function bootGutenbergable()
{
self::deleting(function ($model) {
$model->content()->delete();
});
}
}

0 comments on commit f06517a

Please sign in to comment.