@php $lastDate = null; $lastSessionId = null; @endphp @foreach ($messages as $msg) @php $msgDate = $msg->created_at->toDateString(); $isOutbound = $msg->direction === 'outbound'; $session = $msg->session; @endphp @if ($msg->session_id !== $lastSessionId) @php $sessionStart = $session->created_at->format('d M Y, H:i'); $sessionEnd = $session->window_expires_at ? $session->window_expires_at->format('d M Y, H:i') : '—'; $shortId = substr($session->uuid, 0, 8); @endphp
#{{ $shortId }}  ·  {{ $sessionStart }} → {{ $sessionEnd }}
@php $lastSessionId = $msg->session_id; $lastDate = null; @endphp @endif @if ($msgDate !== $lastDate)
@if ($msg->created_at->isToday()) Today @elseif ($msg->created_at->isYesterday()) Yesterday @else {{ $msg->created_at->format('d M Y') }} @endif
@php $lastDate = $msgDate; @endphp @endif
@if ($isOutbound && $msg->message_type === 'template') @php $decoded = json_decode($msg->content, true); $tplName = $decoded['template_name'] ?? $msg->content; @endphp {{ $tplName }} @else {{ $msg->content }} @endif
{{ $msg->created_at->format('H:i') }} @if ($isOutbound) @if ($msg->status === 'pending') @elseif ($msg->status === 'sent') @elseif ($msg->status === 'delivered') @elseif ($msg->status === 'read') @elseif ($msg->status === 'failed') @endif @endif
@endforeach