Show Correct Currency Values in Edit Views with Laravel Money
Hello đź‘‹,
I’m integrating
laravel-money with the following workflow:
- During record creation, users can enter an amount in their preferred currency (for example, BDT or USD).
- When saving, laravel-money should automatically convert the amount into its minor unit (such as cents).
- When editing, the form should display the value in the original currency chosen by the user.
- When viewing records in tables, the displayed amount should match what’s shown in the edit form.
I’ve already configured the create and show functionality using Eloquent Model attribute casting:
The database table has two columns: price and currency.
My question:
How can I display the correct currency value in the edit form using laravel-money?
https://github.com/cknow/laravel-moneyGitHub
GitHub - cknow/laravel-money: Laravel Money.
Laravel Money. Contribute to cknow/laravel-money development by creating an account on GitHub.
1 Reply
I think I've found a possible answer. I just added these in the Edit record class (for my case, it's
EditProduct.php)