mirror of
https://github.com/wearepixel/laravel-comments.git
synced 2026-11-14 14:02:04 +00:00
Allow deleting replies when comments are deleted.
This commit is contained in:
+11
-1
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user