@extends('front.layout.layout') @section('title', 'My Chats') @section('content')
@if ($chatted_businesses->isNotEmpty())

My Chats

@foreach ($chatted_businesses as $key => $business) @php $bussinesCurrent = $business->business; $isOwner = $bussinesCurrent->user_id === $user->id; $displayName = $isOwner ? "{$business->sender?->first_name} {$business->sender?->last_name}" : $bussinesCurrent->name; $key = "{$business->business_id}_{$business->sender_id}"; $unreadCount = $unreadMessages[$key] ?? 0; @endphp
{{ ucfirst($displayName) }}
{{ $business->created_at->diffForHumans() }} @if ($unreadCount > 0) {{ $unreadCount }} Unread @endif
@endforeach
@else @if (!request()->get('businessId'))
No Chat Found
@forelse ($businesses as $biz)
@empty

No businesses found.

@endforelse
@endif @endif @if ($currentBusiness)
{{ ucfirst($currentBusiness->name) }}
{{ $currentBusiness->address ?? '' }}
@if ($currentBusiness && auth()->id() == $currentBusiness->user_id)
Zoom
@endif
    @if ($messages->isNotEmpty()) @php $lastDate = null; @endphp @foreach ($messages as $message) @php $messageDate = $message->created_at->format('l, d F'); @endphp @if ($lastDate !== $messageDate)
    {{ $messageDate }}
    @php $lastDate = $messageDate; @endphp @endif
  • {{ $message->sender_id == $user->id ? 'You' : $message->sender->first_name . ' ' . $message->sender->last_name }}
    @if (str_starts_with($message->message, 'message !!} @else {{ $message->message }} @endif @if ($message->sender_id == $user->id) {!! $message->is_read ? '✔✔' : '✔' !!} @endif {{ $message->created_at->setTimezone('Asia/Karachi')->format('g:i A') }}

  • @endforeach @else {{--
  • No messages yet.
  • --}} @endif
@if ($currentBusiness)
@endif
@endif
@endsection @push('bottom-scripts') @endpush