Summary makes field which using getStateUsing ignored
raiika opened this issue · comments
Package
filament/filament
Package Version
v3.2
Laravel Version
v11.9
Livewire Version
No response
PHP Version
v8.3
Problem description
In table builder, when you use getStateUsing or formatStateUsing and also use summary with the same column name,
the field which using the thoseStateUsing will be ignored and returning the original column (if not original column, it will return empty).
Expected behavior
The field column should still return the expected result even if it is using summary function.
Steps to reproduce
Table builder example
TextColumn::make('field')
->getStateUsing(fn () => 1),
TextColumn::make('field')
->summarize([
Summarizer::make()
->label('Sum')
->using(fn () => 1)
]),
TextColumn::make('name')
->formatStateUsing(fn (): View => view(
'test_field_2'
)),
TextColumn::make('name')
->summarize([
Summarizer::make()
->using(fn () => 2)
]),
Reproduction repository
https://github.com/raiika/filament-issue-summary
Relevant log output
No response
Summaries execute SQL queries to calculate results. If we didn't do that, they would be very slow, especially the summary row that calculates across multiple pagination pages.
You can use a custom summary to do the calculation using your own function. This could involve doing a $query->get()
and then using the model results: https://filamentphp.com/docs/3.x/tables/summaries#custom-summaries