Skip to content

Commit

Permalink
add delete/forceDelete to comment's boot
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny committed Aug 25, 2022
1 parent 9cb3fcf commit fcb5ced
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Traits/Actions/Comment/isCommentable.php
Expand Up @@ -15,7 +15,11 @@ trait isCommentable
public static function bootIsCommentable()
{
static::deleting(function ($model) {
$model->comments()->delete();
if (in_array(SoftDeletes::class, class_uses($model))) {
$model->comments()->delete();
} else {
$model->comments()->forceDelete();
}
});
}

Expand Down
6 changes: 5 additions & 1 deletion src/Traits/Actions/Comment/isCommenter.php
Expand Up @@ -15,7 +15,11 @@ trait isCommenter
public static function bootIsCommenter()
{
static::deleting(function ($model) {
$model->comments()->delete();
if (in_array(SoftDeletes::class, class_uses($model))) {
$model->comments()->delete();
} else {
$model->comments()->forceDelete();
}
});
}

Expand Down

0 comments on commit fcb5ced

Please sign in to comment.