2

I have a problem with update or save of float value in my DB from PHP/Laravel.

Example:

budget 166.0 -> FLOAT(5,1) in DB

subscription_fee 7.5 -> FLOAT(5,1) in DB

This My code for operations:

foreach ($teams_ctrl as $team_ctrl)

         {
           $budget = $team_ctrl->budget;
           $budget-= $subscription_fee;
           team::where('id', $team_id)->update(['budget' => $budget]);
         }

Now the problem is that...the float value saved/updated in DB is 158.0 instead of 158.5. I tried with floatval, with eloquent save/update....how can i save a right decimal value?

MarSic
  • 33
  • 3

0 Answers0