@if($messages->isEmpty())
No messages yet
@else
@php $lastDate = null; @endphp
@foreach($messages as $msg)
@php
$msgDate = $msg->created_at->toDateString();
$isOutbound = $msg->direction === 'outbound';
@endphp
{{-- Day divider --}}
@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
{{-- Content --}}
@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
{{-- Meta: time + status --}}
{{ $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
@endif
{{-- Reply input / expired banner --}}
@php $windowOpen = $session->window_expires_at && $session->window_expires_at->isFuture(); @endphp
@if($windowOpen)
@else