chat support updates
This commit is contained in:
@@ -41,6 +41,10 @@ class NewChatMessage implements ShouldBroadcastNow
|
|||||||
*/
|
*/
|
||||||
public function broadcastWith()
|
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("DEBUG: NewChatMessage broadcasting on channel ticket.".$this->message->ticket_id);
|
||||||
|
|
||||||
\Log::info("EVENT BROADCAST FIRED", [
|
\Log::info("EVENT BROADCAST FIRED", [
|
||||||
@@ -56,17 +60,20 @@ class NewChatMessage implements ShouldBroadcastNow
|
|||||||
'sender_id' => $this->message->sender_id,
|
'sender_id' => $this->message->sender_id,
|
||||||
'sender_type' => $this->message->sender_type,
|
'sender_type' => $this->message->sender_type,
|
||||||
'message' => $this->message->message,
|
'message' => $this->message->message,
|
||||||
'file_url' => $this->message->file_path
|
|
||||||
? asset('storage/' . $this->message->file_path)
|
// ✅ relative path only
|
||||||
: null,
|
'file_path' => $this->message->file_path ?? null,
|
||||||
'file_type' => $this->message->file_type,
|
'file_type' => $this->message->file_type ?? null,
|
||||||
|
|
||||||
'sender' => [
|
'sender' => [
|
||||||
'id' => $this->message->sender->id,
|
'id' => $this->message->sender->id,
|
||||||
'name' => $this->getSenderName(),
|
'name' => $this->getSenderName(),
|
||||||
'is_admin' => $this->message->sender_type === \App\Models\Admin::class,
|
'is_admin' => $this->message->sender_type === \App\Models\Admin::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
'created_at' => $this->message->created_at->toDateTimeString(),
|
'created_at' => $this->message->created_at->toDateTimeString(),
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -63,17 +63,40 @@
|
|||||||
|
|
||||||
{{-- FILE --}}
|
{{-- FILE --}}
|
||||||
@if($msg->file_path)
|
@if($msg->file_path)
|
||||||
<div class="mt-2">
|
|
||||||
@php $isImage = Str::startsWith($msg->file_type, 'image'); @endphp
|
|
||||||
|
|
||||||
|
@php
|
||||||
|
$isImage = Str::startsWith($msg->file_type, 'image');
|
||||||
|
$isVideo = Str::startsWith($msg->file_type, 'video');
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
{{-- IMAGE --}}
|
||||||
@if($isImage)
|
@if($isImage)
|
||||||
<img src="{{ asset('storage/'.$msg->file_path) }}" style="max-width:150px;" class="rounded">
|
<img
|
||||||
|
src="{{ asset('storage/'.$msg->file_path) }}"
|
||||||
|
style="max-width:150px;"
|
||||||
|
class="rounded"
|
||||||
|
>
|
||||||
|
|
||||||
|
{{-- VIDEO --}}
|
||||||
|
@elseif($isVideo)
|
||||||
|
<video
|
||||||
|
src="{{ asset('storage/'.$msg->file_path) }}"
|
||||||
|
controls
|
||||||
|
style="max-width:200px; border-radius:8px;"
|
||||||
|
>
|
||||||
|
Your browser does not support the video tag.
|
||||||
|
</video>
|
||||||
|
|
||||||
|
{{-- PDF / EXCEL / OTHER --}}
|
||||||
@else
|
@else
|
||||||
<a href="{{ asset('storage/'.$msg->file_path) }}" target="_blank">📎 View Attachment</a>
|
<a href="{{ asset('storage/'.$msg->file_path) }}" target="_blank">
|
||||||
|
📎 View Attachment
|
||||||
|
</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
<small class="text-muted d-block mt-1">
|
<small class="text-muted d-block mt-1">
|
||||||
{{ $msg->created_at->format('d M h:i A') }}
|
{{ $msg->created_at->format('d M h:i A') }}
|
||||||
</small>
|
</small>
|
||||||
@@ -191,14 +214,42 @@ waitForEcho(() => {
|
|||||||
${msg.message ?? ''}
|
${msg.message ?? ''}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
if (msg.file_url) {
|
if (msg.file_path) {
|
||||||
|
|
||||||
|
const fileUrl = `/storage/${msg.file_path}`;
|
||||||
|
|
||||||
if (msg.file_type?.startsWith("image")) {
|
if (msg.file_type?.startsWith("image")) {
|
||||||
html += `<img src="${msg.file_url}" class="rounded mt-2" style="max-width:150px;">`;
|
|
||||||
|
html += `
|
||||||
|
<img
|
||||||
|
src="${fileUrl}"
|
||||||
|
class="rounded mt-2"
|
||||||
|
style="max-width:150px;"
|
||||||
|
>
|
||||||
|
`;
|
||||||
|
|
||||||
|
} else if (msg.file_type?.startsWith("video")) {
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<video
|
||||||
|
src="${fileUrl}"
|
||||||
|
controls
|
||||||
|
class="mt-2"
|
||||||
|
style="max-width:200px; border-radius:8px;"
|
||||||
|
></video>
|
||||||
|
`;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
html += `<a href="${msg.file_url}" target="_blank" class="mt-2 d-block">📎 View File</a>`;
|
|
||||||
|
html += `
|
||||||
|
<a href="${fileUrl}" target="_blank" class="mt-2 d-block">
|
||||||
|
📎 View Attachment
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
<small class="text-muted d-block mt-1">Just now</small>
|
<small class="text-muted d-block mt-1">Just now</small>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user