fix: prevent lazy loading violation on replies relationship

Check relationLoaded('replies') before accessing $comment->replies
to avoid LazyLoadingViolationException when rendering nested comments
whose replies aren't eager loaded.
This commit is contained in:
manukminasyan
2026-03-27 21:23:18 +04:00
parent b44b4e309e
commit 3d745077b7

View File

@@ -142,7 +142,7 @@
@endif
{{-- Nested replies --}}
@if ($comment->replies->isNotEmpty())
@if ($comment->relationLoaded('replies') && $comment->replies->isNotEmpty())
<div class="mt-3 space-y-3 border-l-2 border-gray-200 pl-4 dark:border-gray-700">
@foreach ($comment->replies as $reply)
<livewire:comment-item :comment="$reply" :key="'comment-'.$reply->id" />