FilamentF
Filament11mo ago
gh057x

Table Summarize value based on state

I have a table column called cost, I've added a summarize attributes. How can I summarize all value based on state value?

Tables\Columns\TextColumn::make('cost')
                    ->alignRight()
                    ->state(function ($record) {
                        return costFormula($record->field1, $record->cost);
                    })
                    ->summarize(Tables\Columns\Summarizers\Sum::make())
                    ->numeric()
                    ->prefix('$')
                    ->sortable(),


Currently, the summarize value is based on the original data from database. I want it to be from ->state value
Solution
You could try a custom model property and add that to a new column? Or maybe add a column in the table and adjust it with ->formatStateUsing(function() { })
Was this page helpful?