@extends('provider.layout') @section('title', 'Conversation') @push('styles') @endpush @section('content') @php $authId = auth()->id(); $other = $conversation->otherParticipant($authId); $adUrl = $conversation->safeReferenceUrl(); $displayName = $conversation->getOtherParticipantDisplayName($authId); @endphp {{-- Back link above card --}} Back to Messages @if(session('success'))
{{ session('success') }}
@endif @if($errors->has('message'))
{{ $errors->first('message') }}
@endif {{-- Main chat card --}}
{{-- Header --}}
{{ strtoupper(substr($displayName, 0, 1)) }}
{{ $displayName }}
@if($conversation->subject)
@if($adUrl) {{ Str::limit($conversation->subject, 52) }} @else {{ Str::limit($conversation->subject, 52) }} @endif
@endif
@if($adUrl) View Reference @endif
{{-- Feed --}}
@forelse($conversation->messages as $i => $msg) @php $isMine = $msg->sender_id === $authId; $senderName = $msg->sender->name ?? $msg->sender_name ?? 'User'; $msgDate = $msg->created_at->format('Y-m-d'); $prevDate = $i > 0 ? $conversation->messages[$i-1]->created_at->format('Y-m-d') : null; $showDate = $i === 0 || $msgDate !== $prevDate; $dateLabel = $msg->created_at->isToday() ? 'Today' : ($msg->created_at->isYesterday() ? 'Yesterday' : $msg->created_at->format('d M Y')); @endphp @if($showDate)
{{ $dateLabel }}
@endif
@if(!$isMine)
{{ strtoupper(substr($senderName, 0, 1)) }}
@endif
@if(!$isMine)
{{ $senderName }}
@endif
@if($msg->offer_price)
Offer: {!! \App\Helpers\CurrencyHelper::format($msg->offer_price) !!}
@endif
{{ $msg->message }}
@if(!$isMine && $msg->offer_price && ($msg->sender_phone || $msg->sender_email))
@if($msg->sender_phone) {{ $msg->sender_phone }} @endif @if($msg->sender_email) {{ $msg->sender_email }} @endif
@endif
{{ $msg->created_at->format('h:i A') }} @if($isMine) @if($msg->is_read) Read @else Sent @endif @endif
@if($isMine)
{{ strtoupper(substr(auth()->user()->name, 0, 1)) }}
@endif
@empty
No messages yet. Start the conversation!
@endforelse
{{-- Reply --}}
@csrf
@push('scripts') @endpush @endsection