F
Filament16mo ago
abkrim

Currency factoring 100 (Solved)

I am trying to use filamente admin v3 but I am facing a problem. I keep all my fields related to currency with a factor of 100, so as not to use decimals but whole numbers. Try using -> Tables\Columns\TextColumn::make('price', 100)->money('eur'), but that divides by 100 but rounds to 100 decimal places. Any idea how to do it?
Solution:
do it in the model attribute then everywhere will be consistent
Jump to solution
5 Replies
abkrim
abkrimOP16mo ago
I see solution in Tables - Calculate state
Tables\Columns\TextColumn::make('price')->money('eur')
->state(function (Advert $advert): float {
return $advert->price / 100;
})
->sortable(),
Tables\Columns\TextColumn::make('price')->money('eur')
->state(function (Advert $advert): float {
return $advert->price / 100;
})
->sortable(),
Solution
krekas
krekas16mo ago
do it in the model attribute then everywhere will be consistent
abkrim
abkrimOP16mo ago
Can you explain, pelase?
krekas
krekas16mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
abkrim
abkrimOP16mo ago
Ah.. yes. But I like it in Filament usning reactivity or hidratation. Thanks.
Want results from more Discord servers?
Add your server