@php $inboxTitle = match ($filters['status']) { 'closed' => 'Closed chats', 'archived' => 'Archived chats', default => 'Open chats', }; @endphp @extends('layouts.admin', [ 'active' => 'inbox', 'inboxStatus' => $filters['status'], 'inboxSearch' => $filters['search'], 'inboxConversation' => (bool) $conversation, ]) @section('title', $inboxTitle) @section('heading', $conversation?->user_name ?: $inboxTitle) @section('content') @php $query = array_filter([ 'search' => $filters['search'], 'status' => $filters['status'], ]); $canRealtime = $supabaseUrl !== '' && $supabaseAnonKey !== ''; @endphp
@forelse ($conversations as $row) @php $isActive = $conversation && (int) $conversation->id === (int) $row->id; $preview = $row->latestMessage?->previewText(); $unread = $isActive ? 0 : (int) $row->unread_messages_count; @endphp

{{ $row->user_name ?: $row->user_id }}

Closed @if ($row->updated_at) @endif

{{ $row->domain?->domain_name }}

{{ $preview ?: 'No messages yet' }}

{{ $unread > 99 ? '99+' : ($unread > 0 ? $unread : '') }}
@empty

@if ($filters['search'] !== '') No conversations match that search. @elseif ($filters['status'] === 'closed') No closed chats yet. @elseif ($filters['status'] === 'archived') No archived chats yet. @else No open chats yet. @endif

@endforelse
@if ($conversation)

{{ $conversation->user_name ?: $conversation->user_id }}

User ID {{ $conversation->user_id }} @if ($conversation->domain) · {{ $conversation->domain->domain_name }} @endif

@if ($conversation->isArchived()) Archived @else Closed
@unless ($conversation->isClosed()) @endunless @endif
@forelse ($messages as $message) @include('admin.partials.inbox-message', ['message' => $message, 'conversation' => $conversation]) @empty

No messages yet. Send the first reply.

@endforelse
@csrf @if ($filters['search'] !== '') @endif @php $replyToId = old('reply_to_id'); $replyingTo = $replyToId ? $messages->firstWhere('id', (int) $replyToId) : null; @endphp

{{ $replyingTo?->isFromChatManager() ? 'You' : ($conversation->user_name ?: $conversation->user_id) }}

{{ $replyingTo?->previewText() }}

@error('body')

{{ $message }}

@enderror @error('media')

{{ $message }}

@enderror
@if ($conversation->isArchived())

This chat is archived

You cannot send a reply.

@else

This chat is closed

You cannot send a reply.

@endif @else

Select a conversation

Open a chat from the left to read messages and reply in real time.

@endif
@endsection @section('dialogs') @if ($conversation) @endif @if ($conversation && ! $conversation->isArchived() && ! $conversation->isClosed()) @endif @endsection