philipbaginski
2 weeks ago
104
3
Laravel

Saving values with ->resolveUsing and ->displayUsing

Posted 2 weeks ago by philipbaginski

Hi everyone!

The problem is:

Have a column in database 'odds'. I have to save value in this column divided by 5, but displayed on edit page multiplied by 5. E.g. When I enter value 100 into field, value saved in database should be 20, and displayed value on edit page should be 100.

I used code:

Text::make('Odds') ->resolveUsing(function ($value) { return $value * 5; }) ->fillUsing(function ($value) { return $value / 5; }),

, but it does not work.

Any help?

Please sign in or create an account to participate in this conversation.