[BUG] Formatting multiple columns with summarizeFormat()
dansysanalyst opened this issue · comments
Have you searched through other issues to see if your problem is already reported or has been fixed?
Yes, I did not find it.
Did you read the documentation?
Yes, I did not find it.
Have you tried to publish the views?
Yes - I didn't work.
Is there an error in the console?
No
PHP Version
No response
PowerGrid
No response
Laravel
No response
Livewire
No response
Alpine JS
No response
Theme
Tailwind 3.x
Describe the bug.
No response
To Reproduce...
I would like to format the average summary in two different columns, one as a kcal
and the other as currency $
.
Expected:
Result:
Extra information
Column::make('Calories', 'calories', 'calories')
->withAvg('Average', header: true, footer: false)
->sortable(),
Column::make('Price', 'price_formatted', 'price')
->withSum('Sum Price', header: true, footer: false)
->withAvg('Avg Price', header: true, footer: false)
public function summarizeFormat(): array
{
return [
'calories.{avg}' => fn ($value) => Number::format($value, locale: 'br') . ' kcal',
'price.{sum,avg,min,max}' => fn ($value) => Number::currency($value, in: 'USD'),
'price.{count}' => fn ($value) => Number::format($value, locale: 'br'),
];
}
I should be sending a PR soon fixing this issue.