@props(['comments', 'level' => 0, 'ticket' => null, 'canSeeInternalNotes' => false])
@foreach ($comments as $comment) @php $commentUser = $comment->relationLoaded('user') ? $comment->getRelation('user') : null; $commentAttachments = $comment->relationLoaded('attachments') ? $comment->getRelation('attachments') : collect(); $commentReplies = $comment->relationLoaded('replies') ? $comment->getRelation('replies') : collect(); $replyFormId = 'helpdesk-reply-form-'.$comment->id; $currentTicket = $ticket ?? $comment->ticket ?? null; $replyCount = $commentReplies->count(); $isInternal = (bool) $comment->is_internal; $borderClass = $isInternal ? 'border-amber-300 dark:border-amber-700' : 'border-red-200 dark:border-red-900/70'; $railClass = $isInternal ? 'bg-amber-500' : 'bg-red-500'; @endphp @if (! $isInternal || $canSeeInternalNotes)
{{ $commentUser?->name ?? 'Unknown user' }} {{ $comment->created_at?->format('d M Y H:i') }} {{ $replyCount }} response{{ $replyCount === 1 ? '' : 's' }} @if ($commentAttachments->isNotEmpty()) {{ $commentAttachments->count() }} @endif @if ($isInternal) MPBA internal @endif
@if (! blank($comment->unid)) UNID {{ Str::limit((string) $comment->unid, 16, '') }} @endif @if (! blank($comment->guid)) GUID {{ Str::limit((string) $comment->guid, 18, '') }} @endif
{!! $comment->body !!}
@if ($commentAttachments->isNotEmpty()) @endif @if ($currentTicket !== null)
@endif @if ($commentReplies->isNotEmpty())
@include('helpdesk::partials.comment-thread', [ 'comments' => $commentReplies, 'level' => ((int) $level) + 1, 'ticket' => $currentTicket, 'canSeeInternalNotes' => $canSeeInternalNotes, ])
@endif
@endif @endforeach