Update the value of input field before saving to database
I have a text input field that accept numeric value. The value is to store amount, but before saving to the database, I want to convert that value to cents instead of storing the actual float value. What is the best way to do this?
2 Replies
There is no best way, but I think you can use casts like they use in docs https://filamentphp.com/docs/3.x/panels/getting-started#casting-the-price-to-an-integer or you can defind your own and change base on accessor/mutator.. or you can check using lifecycle hooks provided by filament https://filamentphp.com/docs/3.x/panels/resources/creating-records#lifecycle-hooks
Thank you.