4 months ago

Laravel automatically number formatting decimal column

Posted 4 months ago by Kaylakaze-FE

We have a "promotional_credit" decimal(10,2) column on our customer model. If we go to tinker, and load a customer ($c) and do $c->promotional_credit = 1500, the promotional credit value for that customer shows "1,500.00." Unfortunately, this is more than just a display issue. If we save the customer record, it saves only 1.00 to the database. If we try $c->promotional_credit += 100, we get a "A non well formed numeric value encountered". I can find nowhere in our code where we're running number_format on that value. There is no setPromotionalCredit method or anything in the boot method that touches promotional credit. I tried casting promotional_credit to float, and that still didn't work.

Any help?

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