How can I (eloquently) cascade a soft delete in Laravel? So when there is a post with comments for example, where both tables have soft deletes. When I remove the post, I want to remove the comments at well.
I would expect something like:
class Post extends Model
{
use SoftDeletes;
protected $cascadeSoftDeletes = ['comments'];
...
}
CodePudding user response:
you can do Apollo's solution or you could use a package that handle's this like
https://github.com/michaeldyrynda/laravel-cascade-soft-deletes
CodePudding user response:
To soft delete relations, you have to do it using model observers
https://laracasts.com/discuss/channels/laravel/laravel-soft-delete-cascade Here is an example well explained.