@props(['comments' => [], 'ticket' => null, 'perPage' => 10]) @php $isPaginated = $comments instanceof \Illuminate\Pagination\Paginator || $comments instanceof \Illuminate\Pagination\LengthAwarePaginator; $commentsList = []; $commentCount = 0; if (is_string($comments)) { $commentsList = []; } elseif ($isPaginated) { $commentsList = $comments->items(); $commentCount = $comments->total(); } elseif (is_array($comments)) { $commentsList = $comments; $commentCount = count($comments); } elseif ($comments instanceof \Illuminate\Support\Collection) { $commentsList = $comments->all(); $commentCount = $comments->count(); } elseif (is_object($comments) && method_exists($comments, 'toArray')) { $commentsList = $comments->toArray(); $commentCount = is_countable($commentsList) ? count($commentsList) : 0; } @endphp
@if($commentCount > 0)
@foreach($commentsList as $comment)
@php if ($comment->requester_id ?? $comment['requester_id'] ?? null) { $userName = $comment->requester?->name ?? $comment['requester']['name'] ?? 'S'; } else { $userName = $comment->user?->name ?? $comment['user']['name'] ?? 'S'; } echo strtoupper(substr($userName, 0, 1)); @endphp

@if($comment->requester_id ?? $comment['requester_id'] ?? null) {{ $comment->requester?->name ?? $comment['requester']['name'] ?? 'Solicitante' }} @else {{ $comment->user?->name ?? $comment['user']['name'] ?? 'Usuario' }} @endif

@php $date = $comment->created_at ?? $comment['created_at'] ?? null; if ($date instanceof \DateTime || $date instanceof \Carbon\Carbon) { echo $date->format('d/m/Y H:i'); } else { echo now()->format('d/m/Y H:i'); } @endphp

@if(isset($comment->user) || isset($comment['user'])) Equipo @else Sistema @endif
{{ $comment->content ?? $comment['content'] ?? '—' }}
@endforeach
@if($isPaginated && $comments->hasPages())
{{ $comments->links() }}
@endif @else

No hay comentarios

Aún no hay comentarios en este ticket.

@endif