@extends('admin.layouts.app') @section('page-title', 'Chat With ' . ($ticket->user->customer_name ?? $ticket->user->name)) @section('content')
{{-- per‑ticket new message notification --}}
New messages: 0
{{ ucfirst($ticket->status) }} Back
{{-- Messages --}}
@foreach($messages as $msg)
@if($msg->message)
{{ $msg->message }}
@endif @if($msg->file_path) @php $isImage = Str::startsWith($msg->file_type, 'image'); $isVideo = Str::startsWith($msg->file_type, 'video'); $isPdf = Str::endsWith($msg->file_path, '.pdf'); $isDocument = in_array(Str::lower(Str::afterLast($msg->file_path, '.')), ['doc', 'docx', 'txt']); $fileName = basename($msg->file_path); $fileSize = 'N/A'; try { $fullPath = storage_path('app/public/' . $msg->file_path); if (file_exists($fullPath)) { $size = filesize($fullPath); if ($size < 1024) { $fileSize = $size . ' B'; } elseif ($size < 1048576) { $fileSize = round($size / 1024, 1) . ' KB'; } else { $fileSize = round($size / 1048576, 1) . ' MB'; } } } catch (Exception $e) { $fileSize = 'Unknown'; } if ($isImage) { $fileClass = 'image-file'; $fileIcon = '🖼️'; } elseif ($isVideo) { $fileClass = 'video-file'; $fileIcon = '🎬'; } elseif ($isPdf) { $fileClass = 'pdf-file'; $fileIcon = '📄'; } elseif ($isDocument) { $fileClass = 'document-file'; $fileIcon = '📝'; } else { $fileClass = 'other-file'; $fileIcon = '📎'; } @endphp
@if($isImage) {{ $fileName }} @elseif($isVideo) @endif
{{ $fileIcon }}
{{ $fileName }}
{{ $fileSize }}
@endif {{ $msg->created_at->format('d M h:i A') }}
@endforeach
{{-- Input --}}
@endsection @section('scripts') @endsection