@extends('provider.layout') @section('title', 'Messages') @push('styles') @endpush @section('content') @php $userId = auth()->id(); $totalUnread = $conversations->sum(fn($c) => $c->unreadCountFor($userId)); @endphp {{-- Page Header --}}

Messages

Your conversations with customers.

@if($totalUnread > 0)
{{ $totalUnread }} unread
@endif
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Empty State --}} @if($conversations->isEmpty())
No messages yet
When customers contact you, their messages will appear here.
{{-- Conversation List --}} @else
@foreach($conversations as $conv) @php $other = $conv->otherParticipant($userId); $latest = $conv->latestMessage; $unread = $conv->unreadCountFor($userId); $isUnread = $unread > 0; $displayName = $conv->getOtherParticipantDisplayName($userId); $initials = strtoupper(substr($displayName, 0, 1)); $adUrl = $conv->safeReferenceUrl(); @endphp
{{ $initials }}
{{ $other->name ?? 'Unknown User' }} {{ $conv->last_message_at?->diffForHumans() ?? '' }}
@if($conv->subject)
{{ Str::limit($conv->subject, 48) }}
@endif
@if($latest) @if($latest->sender_id === $userId)You: @endif {{ Str::limit($latest->message, 72) }} @else No messages yet @endif
@if($isUnread)
{{ $unread > 9 ? '9+' : $unread }}
@endif
@endforeach
@endif @endsection