F
Filament12mo ago
toeknee

Summerise when using cents?

As I am now storing values as intergers, what's the recommend approach for Summerising? Wondering if we should just cast at * 100 by default?
Solution:
Answer:
->money('EUR', 100)
->money('EUR', 100)
...
Jump to solution
2 Replies
toeknee
toekneeOP12mo ago
i.e.
TextColumn::make('total')
->label('Total')
->alignCenter()
->toggleable()
->formatStateUsing(
fn ($state): string => (number_format((float) $state, 2))
)
->summarize([
Tables\Columns\Summarizers\Sum::make()

->numeric(
decimalPlaces: 0,
decimalSeparator: '.',
thousandsSeparator: ',',
)
->label('Total'),
])
->default(0),
TextColumn::make('total')
->label('Total')
->alignCenter()
->toggleable()
->formatStateUsing(
fn ($state): string => (number_format((float) $state, 2))
)
->summarize([
Tables\Columns\Summarizers\Sum::make()

->numeric(
decimalPlaces: 0,
decimalSeparator: '.',
thousandsSeparator: ',',
)
->label('Total'),
])
->default(0),
How do we cast the value to dollars since formatStateUsing doesn't work on Sum
Solution
toeknee
toeknee12mo ago
Answer:
->money('EUR', 100)
->money('EUR', 100)
Want results from more Discord servers?
Add your server