Triggering on Card to show table

Even after emitting the event and clicking the card, the showTable method does not seem to be triggering as expected. It does not show the table
class StatsOverview extends BaseWidget
{
protected static ?int $sort = 3;
protected function getStats(): array
{
return [
$this->getCheckedInGuests(),
];
}


protected function getCheckedInGuests(): Card
{
$count = Reservation::where('status', 'Checked In')->count();

return Card::make('Checked-In Guests', $count)
->description('Number of guests currently checked in')
->descriptionIcon('heroicon-o-user-group')
->color('success')
->extraAttributes([
'class' => 'cursor-pointer hover:#54effd7a md:col-span-2 lg:col-span-2',
'wire:click' => "\$emit('showCheckedInGuests')"
]);
}
}
class StatsOverview extends BaseWidget
{
protected static ?int $sort = 3;
protected function getStats(): array
{
return [
$this->getCheckedInGuests(),
];
}


protected function getCheckedInGuests(): Card
{
$count = Reservation::where('status', 'Checked In')->count();

return Card::make('Checked-In Guests', $count)
->description('Number of guests currently checked in')
->descriptionIcon('heroicon-o-user-group')
->color('success')
->extraAttributes([
'class' => 'cursor-pointer hover:#54effd7a md:col-span-2 lg:col-span-2',
'wire:click' => "\$emit('showCheckedInGuests')"
]);
}
}
The table --
class LatestChecked extends BaseWidget
{
public $showTable = false;

protected $listeners = ['showCheckedInGuests' => 'showTable'];

public function showTable()
{
$this->showTable = true;
Log::info('showTable triggered: ' . $this->showTable);
}

protected function getTableQuery(): Builder
{
if ($this->showTable) {
Log::info('Table should be shown.');
return CheckInCheckOut::query()->latest();
}

Log::info('Table is hidden.');
return CheckInCheckOut::query()->whereNull('id');
}

}
class LatestChecked extends BaseWidget
{
public $showTable = false;

protected $listeners = ['showCheckedInGuests' => 'showTable'];

public function showTable()
{
$this->showTable = true;
Log::info('showTable triggered: ' . $this->showTable);
}

protected function getTableQuery(): Builder
{
if ($this->showTable) {
Log::info('Table should be shown.');
return CheckInCheckOut::query()->latest();
}

Log::info('Table is hidden.');
return CheckInCheckOut::query()->whereNull('id');
}

}
class Dashboard extends BaseDashboard { use BaseDashboard\Concerns\HasFiltersForm; protected static ?int $navigationSort = -2; protected static string $routePath = 'Dashboard'; protected static ?string $title = 'Dashboard'; public function getWidgets(): array { return [ AccountWidget::class, FilamentInfoWidget::class, StatsOverview::class, LatestChecked::class, ]; } }```
Solution:
Try $dispatch, $emit was removed in v3 of livewire.
Jump to solution
1 Reply
Solution
awcodes
awcodes4mo ago
Try $dispatch, $emit was removed in v3 of livewire.
Want results from more Discord servers?
Add your server