Allow deleting replies when comments are deleted.

This commit is contained in:
3m1n3nc3
2024-07-09 04:44:30 +01:00
parent d5a15036b8
commit e9663034fe
8 changed files with 154 additions and 8 deletions
+11 -1
View File
@@ -3,6 +3,7 @@
namespace BeyondCode\Comments\Tests\Models;
use BeyondCode\Comments\Traits\HasComments;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
@@ -10,4 +11,13 @@ class Post extends Model
use HasComments;
protected $guarded = [];
}
public static function boot(): void
{
parent::boot();
static::deleting(function (self $model) {
$model->comments()->delete();
});
}
}