Grouped row in Filament together with action

I have the following table in Filament:
public function getIncentiveRequests(): Builder
{
return OIPRequest::query()
->selectRaw('
ROW_NUMBER() OVER (ORDER BY branch_id, department_id, business_type, expire_at) as id,
branch_id,
department_id,
business_type,
expire_at,
GROUP_CONCAT(id SEPARATOR \',\') as original_ids
')
->where('status', 'approved')
->where('branch_id', 1) // Adjust this as needed
->where('expire_at', '>', '2024-08-01')
->groupBy('branch_id', 'department_id', 'business_type', 'expire_at');
}

public function table(Table $table): Table
{
return $table
->query(function (): Builder {
return $this->getIncentiveRequests();
})
->modifyQueryUsing($this->modifyQueryWithActiveTab(...))
->columns([
TextColumn::make('department.name')
->label('Department')
->sortable(),
TextColumn::make('gp')
->label('GP')
->money('eur', true)
->state(function ($record) {
return $this->calculateGP($record);
})
->sortable()
])
->actions([
ActionGroup::make([
Action::make('Links')->action(fn (OIPRequest $record) => dd($record))
])
])
}
public function getIncentiveRequests(): Builder
{
return OIPRequest::query()
->selectRaw('
ROW_NUMBER() OVER (ORDER BY branch_id, department_id, business_type, expire_at) as id,
branch_id,
department_id,
business_type,
expire_at,
GROUP_CONCAT(id SEPARATOR \',\') as original_ids
')
->where('status', 'approved')
->where('branch_id', 1) // Adjust this as needed
->where('expire_at', '>', '2024-08-01')
->groupBy('branch_id', 'department_id', 'business_type', 'expire_at');
}

public function table(Table $table): Table
{
return $table
->query(function (): Builder {
return $this->getIncentiveRequests();
})
->modifyQueryUsing($this->modifyQueryWithActiveTab(...))
->columns([
TextColumn::make('department.name')
->label('Department')
->sortable(),
TextColumn::make('gp')
->label('GP')
->money('eur', true)
->state(function ($record) {
return $this->calculateGP($record);
})
->sortable()
])
->actions([
ActionGroup::make([
Action::make('Links')->action(fn (OIPRequest $record) => dd($record))
])
])
}
If I dump the $record from the text column's state function, it successfully returns all the original_ids from my query comma seperated (2,4,5). However, if I dump the $record from the action, it only takes the first one: original_ids => 2 How can I get all the original_ids in the action for my grouped record?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server