Table actions not firing

I have a table function in a custom Filament page: I have initialized the page like this:
<?php

//...
use Filament\Tables\Actions\Action;
//...

class IncentiveOverview extends Page implements HasTable, HasForms, HasActions
{
use InteractsWithTable;
use InteractsWithForms;
use InteractsWithActions;
use HasTabs;
<?php

//...
use Filament\Tables\Actions\Action;
//...

class IncentiveOverview extends Page implements HasTable, HasForms, HasActions
{
use InteractsWithTable;
use InteractsWithForms;
use InteractsWithActions;
use HasTabs;
Table:
public function table(Table $table): Table
{
return $table
->query(function (): Builder {
return $this->getIncentiveRequests()->groupBy(['branch_id', 'department_id']);
})
->modifyQueryUsing($this->modifyQueryWithActiveTab(...))
->columns([
TextColumn::make('department.name')
->label('Department')
->sortable(),
])
->actions([
Action::make('view_incentive_details')
->label('View Incentive Details')
->action(function ($record) {
dd($record);
})
]);
}
public function table(Table $table): Table
{
return $table
->query(function (): Builder {
return $this->getIncentiveRequests()->groupBy(['branch_id', 'department_id']);
})
->modifyQueryUsing($this->modifyQueryWithActiveTab(...))
->columns([
TextColumn::make('department.name')
->label('Department')
->sortable(),
])
->actions([
Action::make('view_incentive_details')
->label('View Incentive Details')
->action(function ($record) {
dd($record);
})
]);
}
Then, the blade view is looking like this:
<x-filament::page>
<div class="flex flex-col gap-4">
<x-filament-panels::resources.tabs />
<div class="relative">
{{ $this->table }}
</div>
<x-filament-actions::modals />
</div>
</x-filament::page>
<x-filament::page>
<div class="flex flex-col gap-4">
<x-filament-panels::resources.tabs />
<div class="relative">
{{ $this->table }}
</div>
<x-filament-actions::modals />
</div>
</x-filament::page>
When I try to trigger the view_incentive_details, I would for now, expect that it would just dd the $record, however, when I click it, a spinner is just shown briefly: !image
4 Replies
Dennis Koch
Dennis Koch4mo ago
What is >getIncentiveRequests() returning? Do the record still have a ID? Might also be because of the groupBy statement 🤔
oliverbusk
oliverbuskOP4mo ago
It's returning this:
public function getIncentiveRequests() : Builder
{
return OIPRequest::query()
->with(['department', 'branch'])
->select('branch_id', 'department_id', 'business_type', 'expire_at')
->where('status', 'approved');
}
public function getIncentiveRequests() : Builder
{
return OIPRequest::query()
->with(['department', 'branch'])
->select('branch_id', 'department_id', 'business_type', 'expire_at')
->where('status', 'approved');
}
I tried to scrape the class of everything, and just return a table with a standard query (like: OIPRequest::query()), but to no avail 😦
Dennis Koch
Dennis Koch4mo ago
Does it have an id column? At least in the query above you didn’t select it.
oliverbusk
oliverbuskOP3mo ago
No, I am not selecting any id column, since the table is grouped: However, I am setting a record key for the table:
public function getTableRecordKey($record): string
{
return 'department_' . $record->department_id;
}
public function getTableRecordKey($record): string
{
return 'department_' . $record->department_id;
}
After adding id to the select it works! Thank you Dennis! However, shouldn't the getTableRecordKey do the same as replacing the id ?
Want results from more Discord servers?
Add your server