F
Filament15mo ago
Panda

Is it possible to modify the aggregation column query?

I am currently loading the sum of amount field from transactions relation on my CoinsPack model using the following code. The Transaction has a status field which can be either pending, cancelled and successful and I want the sum of amount column for only successful transactions.
Tables\Columns\TextColumn::make('transactions_sum_amount')
->sum('transactions', 'amount')
->money('USD')
->label('Sales')
->placeholder('No sales'),
Tables\Columns\TextColumn::make('transactions_sum_amount')
->sum('transactions', 'amount')
->money('USD')
->label('Sales')
->placeholder('No sales'),
5 Replies
Panda
PandaOP15mo ago
I've tried to modify the query using the table method in listing page but I guess it has a bug as when added, the entire table disappears (rows and header) and only the pagination row is visible. https://filamentphp.com/docs/3.x/panels/resources/listing-records#customizing-the-table-eloquent-query
No description
No description
DarkKnight
DarkKnight15mo ago
Filament
Aggregate data in table footer (sum, avg...etc) by moaaz faracheh -...
Filament is a collection of tools for rapidly building beautiful TALL stack apps, designed for humans.
DarkKnight
DarkKnight15mo ago
even though its technically for v2, i believe its more or less the same for v3
Panda
PandaOP15mo ago
I ended up defining a new successfulTransactions relation on the CoinPack and summing through it.
DarkKnight
DarkKnight15mo ago
nice, good job
Want results from more Discord servers?
Add your server