{{-- Sidebar: Conversations --}}
{{-- Title & Search --}}
Chats
@if ($searchResults->isNotEmpty())
    @foreach ($searchResults as $result)
  • @endforeach
@endif
{{-- List --}}
@foreach ($conversations as $conv) @php $other = $conv->otherParticipants($conv->participant($place))->first()?->participant; if ($other == null) { $other = $conv->otherParticipants($conv->participant($place), true) ->where('participant_type', '!=', $place::class) ->where('participant_id', '!=', $place->id) ->first()?->participant; } @endphp
{{-- Main click area --}} @php $count = $unreadCounts[$conv->public_id] ?? 0; @endphp @if($count > 0) {{ $count }} @endif {{-- Delete convo button --}}
@endforeach
{{-- Chat Pane --}}
{{-- Header --}}
@if($activeConversation != null) @php $other = $activeConversation->otherParticipants($activeConversation->participant($place))->first()?->participant; if ($other == null) { $other = $activeConversation->otherParticipants($activeConversation->participant($place), true) ->where('participant_type', '!=', $place::class) ->where('participant_id', '!=', $place->id) ->first()?->participant; } @endphp
{{ $other?->getSearchNameAttribute() }}
{{ $otherTyping ? 'Typingโ€ฆ' : optional($activeConversation->lastMessage)->created_at?->diffForHumans() }}
@else
Select a Conversation
@endif
{{-- Messages --}}
@if ($activeConversation) @foreach ($messages as $msg) @php $actingUser = $msg->actingAsUser; $actingEmployee = $actingUser?->employee; $actsForThisPlace = $actingEmployee?->places->contains($place->id) ?? false; $isMine = ( (($msg->sender_type ?? '') === \App\Models\Place::class && $msg->sender_id === $place->id) || $actsForThisPlace ); @endphp
! $isMine, 'bg-gray-900 text-white rounded-tl-lg rounded-tr-lg rounded-bl-lg' => $isMine, ]) > {{-- Delete button --}} @if ($isMine) @endif {{-- Message text --}} @if($actsForThisPlace && $actingUser)
Sent by {{ $actingUser->getSearchNameAttribute() }}
@endif
{{ $msg->body }}
{{-- Attachments carousel --}} @if ($msg->attachments->isNotEmpty()) @endif {{-- Timestamp --}} @php // Determine status for *your* messages only $status = 'sent'; if ($msg->receipts->contains(fn($r) => $r->status === \App\Enums\Chat\ReceiptStatus::READ)) { $status = 'read'; } elseif ($msg->receipts->contains(fn($r) => $r->status === \App\Enums\Chat\ReceiptStatus::DELIVERED)) { $status = 'delivered'; } @endphp @if ($isMine)
{{-- timestamp --}} {{ $msg->created_at->format('H:i') }} {{-- status ticks --}} @if($status === 'sent') {{-- single gray check --}} @elseif($status === 'delivered') {{-- double gray checks overlapped --}} @else {{-- read --}} {{-- double blue checks overlapped --}} @endif
@else {{-- keep non-mine timestamp as before --}}
{{ $msg->created_at->format('H:i') }}
@endif
@endforeach @else
No conversation selected
@endif
{{-- Input area --}} @if ($activeConversation)
{{-- Preview selected attachments --}} @if (! empty($attachmentUploads))
@foreach ($attachmentUploads as $f) {{ $f->getClientOriginalName() }} @endforeach
@endif
@endif