@extends('app::layouts.app') @section('title', 'Inbox') @section('content')
@include('panel.partials.sidebar', ['activeMenu' => 'inbox'])
@include('panel.partials.page-header', [ 'title' => 'Inbox', 'description' => 'Read and reply to buyer messages from the same panel shell used across the site.', 'actions' => $requiresLogin ?? false ? new \Illuminate\Support\HtmlString('Log in') : null, ])
@if($requiresLogin ?? false)

Inbox

Stay on this page and log in when you want to access your conversations.

@endif
@forelse($conversations as $conversation) @php $conversationListing = $conversation->listing; $partner = (int) $conversation->buyer_id === (int) auth()->id() ? $conversation->seller : $conversation->buyer; $isSelected = $selectedConversation && (int) $selectedConversation->id === (int) $conversation->id; $conversationImage = $conversationListing?->getFirstMediaUrl('listing-images'); $lastMessage = trim((string) ($conversation->lastMessage?->body ?? '')); @endphp
@if($conversationImage) {{ $conversationListing?->title }} @else
Listing
@endif

{{ $partner?->name ?? 'User' }}

{{ $conversation->last_message_at?->format('d.m.Y') }}

{{ $conversationListing?->title ?? 'Listing removed' }}

{{ $lastMessage !== '' ? $lastMessage : 'No messages yet' }}

@if($conversation->unread_count > 0) {{ $conversation->unread_count }} @endif
@empty
No conversations yet.
@endforelse
@if($selectedConversation) @php $activeListing = $selectedConversation->listing; $activePartner = (int) $selectedConversation->buyer_id === (int) auth()->id() ? $selectedConversation->seller : $selectedConversation->buyer; $activePriceLabel = $activeListing && !is_null($activeListing->price) ? number_format((float) $activeListing->price, 0).' '.($activeListing->currency ?? 'TL') : null; @endphp
{{ strtoupper(substr((string) ($activePartner?->name ?? 'K'), 0, 1)) }}

{{ $activePartner?->name ?? 'User' }}

{{ $activeListing?->title ?? 'Listing removed' }}

@if($activePriceLabel)
{{ $activePriceLabel }}
@endif
@forelse($selectedConversation->messages as $message) @php $isMine = (int) $message->sender_id === (int) auth()->id(); @endphp
{{ $message->body }}

{{ $message->created_at?->format('H:i') }}

@empty

No messages yet.

Use a quick reply or send the first message below.

@endforelse
@foreach($quickMessages as $quickMessage)
@csrf
@endforeach
@csrf
@error('message')

{{ $message }}

@enderror
@else

Choose a conversation to start messaging.

Start a new chat from a listing detail page or continue an existing thread here.

@endif
@endsection