@extends('layouts.app') @section('title', 'Chat') @section('content')

Messages

@php $otherUser = $chat->buyer_id === auth()->id() ? $chat->seller : $chat->buyer; @endphp Chat with {{ $otherUser->name }}

Back to Conversations

Conversations

@if($allChats->count() > 0) @else

No conversations

Start a conversation from the marketplace.

@endif
{{ strtoupper(substr($otherUser->name, 0, 1)) }}

{{ $otherUser->name }} @if($otherUser->company_name) ({{ $otherUser->company_name }}) @endif

{{ auth()->user()->isBuyer() ? 'Seller' : 'Buyer' }}

About Product

{{ $chat->product->name }}

${{ number_format($chat->product->price, 2) }}

@if($messages->count() > 0)
@foreach($messages->reverse() as $message)

{{ $message->message }}

{{ $message->created_at->format('g:i A') }} @if($message->sender_id === auth()->id() && $message->is_read) @endif
@endforeach
@else

No messages yet

Start the conversation by sending a message.

@endif
@csrf
@if($messages->count() > 0)
{{ $messages->links() }}
@endif
@endsection