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:
@@ -142,7 +142,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
{{-- Nested replies --}}
|
{{-- 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">
|
<div class="mt-3 space-y-3 border-l-2 border-gray-200 pl-4 dark:border-gray-700">
|
||||||
@foreach ($comment->replies as $reply)
|
@foreach ($comment->replies as $reply)
|
||||||
<livewire:comment-item :comment="$reply" :key="'comment-'.$reply->id" />
|
<livewire:comment-item :comment="$reply" :key="'comment-'.$reply->id" />
|
||||||
|
|||||||
Reference in New Issue
Block a user