fix: include replies in comment count and cascade delete to replies

This commit is contained in:
ilyapashayan
2026-03-30 18:59:07 +04:00
parent 20dba18e8e
commit 812556cba2
3 changed files with 12 additions and 2 deletions

View File

@@ -28,6 +28,10 @@ class Comment extends Model
$comment->body = Str::sanitizeHtml($comment->body);
});
static::deleting(function (self $comment): void {
$comment->replies()->each(fn ($reply) => $reply->delete());
});
static::forceDeleting(function (self $comment): void {
$comment->attachments()->delete();
$comment->reactions()->delete();