@extends('admin.layouts.master') @section('title', $title) @section('contents')

{{ trans('Conversations for') }}: {{ $project->title }}

{{ trans('Back to Projects') }}
@forelse($chats as $chat)
{{ trans('Owner') }}: {{ $chat->owner->name ?? trans('Unknown') }} ({{ $chat->owner->email ?? '' }})       {{ trans('Freelancer') }}: {{ $chat->freelancer->name ?? trans('Unknown') }} ({{ $chat->freelancer->email ?? '' }})
{{ $chat->messages->count() }} {{ __('Messages') }}
@if($chat->messages->isEmpty())

{{ trans('No messages in this conversation.') }}

@else
@foreach($chat->messages->sortBy('created_at') as $message) @php $isOwner = $message->sender_id == $chat->owner_id; @endphp
{{ $message->sender->name ?? trans('Unknown') }} {{ $message->created_at->diffForHumans() }} @if($message->is_read) @else @endif
@if($message->message)

{{ is_array($message->message) ? implode(' ', $message->message) : (string) $message->message }}

@endif @php $attachments = $chat->getMedia('chats') ->filter(fn($m) => (int) data_get($m->custom_properties, 'message_id') === (int) $message->id); @endphp @if($attachments->isNotEmpty())
@foreach($attachments as $file) @php $mime = (string) $file->mime_type; $fileName = (string) $file->file_name; $isImage = str_starts_with($mime, 'image/') || preg_match('/\.(jpe?g|png|gif|webp|bmp|svg)$/i', $fileName); $isAudio = str_starts_with($mime, 'audio/') || preg_match('/\.(webm|ogg|mp3|m4a|wav|aac|opus)$/i', $fileName); @endphp @if($isImage) {{ $file->file_name }} @elseif($isAudio)
@else {{ $file->file_name }} @endif @endforeach
@endif
@endforeach
@endif
@empty

{{ trans('No conversations found for this project.') }}

@endforelse
@endsection @section('css') @endsection