Level 3
Same issue here
I'm encountering an issue with event handling between a Laravel component and a Filament 3 page. I've set up an event dispatch in my component, but the Filament page isn't responding as expected. Here's my setup:
Laravel Component (in the resources folder):
<div x-data="chatwootIntegration()" x-init="init">
<!-- UI elements can be added here if needed -->
</div>
<script>
function chatwootIntegration() {
return {
// ... other methods ...
handleAppContextEvent(data) {
if (data.contact && data.contact.phone_number) {
const { code, number } = this.parsePhoneNumber(data.contact.phone_number);
Livewire.dispatch('updatePhoneNumber', { code, number });
console.log('Dispatched updatePhoneNumber event');
} else {
console.log('No contact phone number found in data');
}
},
// ... other methods ...
}
}
</script>
Filament 3 Page Blade:
<x-filament-panels::page>
<x-chatwoot-integration />
{{ $this->table }}
</x-filament-panels::page>
Filament 3 Page Class:
use Livewire\Attributes\On;
class Orders extends Page implements HasTable
{
use InteractsWithTable;
protected static string $view = 'filament.pages.kaurzon.orders';
protected static bool $shouldRegisterNavigation = false;
public ?string $mobileCode = null;
public ?string $mobileNumber = null;
public function mount()
{
if (!$this->validateKey()) {
abort(403);
}
}
protected function validateKey()
{
// Implement key validation logic
}
protected function getTableQuery()
{
// Implement order query logic
}
protected function getTableColumns()
{
return [
// Define table columns
];
}
#[On('updatePhoneNumber')]
public function updatePhoneNumber($code, $number)
{
logger("updatePhoneNumber received");
logger("Code: " . $code);
logger("Number: " . $number);
$this->mobileCode = $code;
$this->mobileNumber = $number;
}
}
The event is being dispatched from the Laravel component, but it's not being received by the Filament page. I've added logging statements to verify if the updatePhoneNumber method is being called, but it doesn't seem to be triggering. Any suggestions on how to properly set up this event listening in Filament 3 would be greatly appreciated.
Please or to participate in this conversation.