From 5dc9fc7db426d94bf521cf849c7306179ae8570702044609a596fa487ab06417 Mon Sep 17 00:00:00 2001 From: Abhishek Mali Date: Tue, 16 Dec 2025 10:19:54 +0530 Subject: [PATCH] chat support updates --- app/Events/NewChatMessage.php | 23 ++++--- resources/views/admin/chat_window.blade.php | 73 +++++++++++++++++---- 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/app/Events/NewChatMessage.php b/app/Events/NewChatMessage.php index 27f92f7..8cf8c58 100644 --- a/app/Events/NewChatMessage.php +++ b/app/Events/NewChatMessage.php @@ -40,7 +40,11 @@ class NewChatMessage implements ShouldBroadcastNow * Data sent to frontend (Blade + Flutter) */ public function broadcastWith() - { + { + \Log::info('APP_URL USED IN EVENT', [ + 'url' => config('app.url'), +]); + \Log::info("DEBUG: NewChatMessage broadcasting on channel ticket.".$this->message->ticket_id); \Log::info("EVENT BROADCAST FIRED", [ @@ -56,17 +60,20 @@ class NewChatMessage implements ShouldBroadcastNow 'sender_id' => $this->message->sender_id, 'sender_type' => $this->message->sender_type, 'message' => $this->message->message, - 'file_url' => $this->message->file_path - ? asset('storage/' . $this->message->file_path) - : null, - 'file_type' => $this->message->file_type, + + // ✅ relative path only + 'file_path' => $this->message->file_path ?? null, + 'file_type' => $this->message->file_type ?? null, + 'sender' => [ - 'id' => $this->message->sender->id, - 'name' => $this->getSenderName(), - 'is_admin' => $this->message->sender_type === \App\Models\Admin::class, + 'id' => $this->message->sender->id, + 'name' => $this->getSenderName(), + 'is_admin' => $this->message->sender_type === \App\Models\Admin::class, ], + 'created_at' => $this->message->created_at->toDateTimeString(), ]; + } /** diff --git a/resources/views/admin/chat_window.blade.php b/resources/views/admin/chat_window.blade.php index d07630b..2dec287 100644 --- a/resources/views/admin/chat_window.blade.php +++ b/resources/views/admin/chat_window.blade.php @@ -63,17 +63,40 @@ {{-- FILE --}} @if($msg->file_path) -
- @php $isImage = Str::startsWith($msg->file_type, 'image'); @endphp - @if($isImage) - - @else - 📎 View Attachment - @endif -
+ @php + $isImage = Str::startsWith($msg->file_type, 'image'); + $isVideo = Str::startsWith($msg->file_type, 'video'); + @endphp + + {{-- IMAGE --}} + @if($isImage) + + + {{-- VIDEO --}} + @elseif($isVideo) + + + {{-- PDF / EXCEL / OTHER --}} + @else + + 📎 View Attachment + + @endif + @endif + {{ $msg->created_at->format('d M h:i A') }} @@ -191,14 +214,42 @@ waitForEcho(() => { ${msg.message ?? ''} `; - if (msg.file_url) { + if (msg.file_path) { + + const fileUrl = `/storage/${msg.file_path}`; + if (msg.file_type?.startsWith("image")) { - html += ``; + + html += ` + + `; + + } else if (msg.file_type?.startsWith("video")) { + + html += ` + + `; + } else { - html += `📎 View File`; + + html += ` + + 📎 View Attachment + + `; } } + html += ` Just now