listener not working via echo
I've a custom page in filament whose view is here:
I am successfully able to dispatch an event CustomerAskedQuestion using laravel event. But I am not able to listen to it in this above mentioned filament custom page view file, neither in the class file like below:
I get Laravel Echo not found error, not sure what should I do to mitigate this error? Noob question I believe?
<x-filament-panels::page>
{{ $record->name }}
@foreach ($record->unAnsweredChatSessions as $chatSession)
<a href="#" wire:click="fetchMessages({{ $chatSession->id }})">
{{ $chatSession->oldestMessage->message }}
</a>
<br />
@endforeach
@if ($selectChatSessionId > 0)
<div>
<h2>Chat Session with {{ $selectChatSessionId }}</h2>
<div>
@foreach ($selectedSessionMessages->messages as $message)
<div>
{{ $message->message }} <br><br>
</div>
@endforeach
</div>
<input type="text" wire:model="newMessage" />
<input type="submit" wire:click="sendMessage" />
</div>
@endif
</x-filament-panels::page>
@script
<script type="module">
Echo.private(`new-chat-for-{{ $selectChatSessionId }}`)
.listen('adminchatnotification', (e) => {
$wire.$refresh()
});
</script>
@endscript<x-filament-panels::page>
{{ $record->name }}
@foreach ($record->unAnsweredChatSessions as $chatSession)
<a href="#" wire:click="fetchMessages({{ $chatSession->id }})">
{{ $chatSession->oldestMessage->message }}
</a>
<br />
@endforeach
@if ($selectChatSessionId > 0)
<div>
<h2>Chat Session with {{ $selectChatSessionId }}</h2>
<div>
@foreach ($selectedSessionMessages->messages as $message)
<div>
{{ $message->message }} <br><br>
</div>
@endforeach
</div>
<input type="text" wire:model="newMessage" />
<input type="submit" wire:click="sendMessage" />
</div>
@endif
</x-filament-panels::page>
@script
<script type="module">
Echo.private(`new-chat-for-{{ $selectChatSessionId }}`)
.listen('adminchatnotification', (e) => {
$wire.$refresh()
});
</script>
@endscriptI am successfully able to dispatch an event CustomerAskedQuestion using laravel event. But I am not able to listen to it in this above mentioned filament custom page view file, neither in the class file like below:
public function getListeners()
{
return [
"echo:adminchatnotification,.new-chat-for-{$this->selectChatSessionId}" => 'fetchMessages',
];
}
public function fetchMessages($selectChatSessionId)
{
dd('event captured');
} public function getListeners()
{
return [
"echo:adminchatnotification,.new-chat-for-{$this->selectChatSessionId}" => 'fetchMessages',
];
}
public function fetchMessages($selectChatSessionId)
{
dd('event captured');
}I get Laravel Echo not found error, not sure what should I do to mitigate this error? Noob question I believe?