F
Filament7mo ago
Andi

Table summary not working for accessors

Hello I try to build a summary for an accessor, which counts an amount of a hasMany relationship.
Tables\Columns\TextColumn::make('totalValue')
->label('Total Value')
->formatStateUsing(fn($state) => number_format($state, 2))
->sortable()
->money('EUR'),
Tables\Columns\TextColumn::make('totalValue')
->label('Total Value')
->formatStateUsing(fn($state) => number_format($state, 2))
->sortable()
->money('EUR'),
this works as expected, but when I add the summary:
->summarize(Tables\Columns\Summarizers\Sum::make()
->label('Total Sum')
->formatStateUsing(fn($state) => number_format($state, 2))
)
->summarize(Tables\Columns\Summarizers\Sum::make()
->label('Total Sum')
->formatStateUsing(fn($state) => number_format($state, 2))
)
this breaks because totalValue doesn't exist as a column.
1 Reply
Povilas K
Povilas K7mo ago
Maybe try custom summaries repeating the same condition as in the accessor: https://filamentphp.com/docs/3.x/tables/summaries#custom-summaries Not convenient, but should work.
Want results from more Discord servers?
Add your server