@fredsparis how are you passing it to the vue? Show us some code.
Feb 24, 2020
4
Level 1
Laravel eloquent returns string for decimal
Hello,
I wonder if someone ever had this issue.
I store a number in the database as a decimal. For example: 10.2. The column in the mysql database is set as "decimal" type.
When I fetch the data using Eloquent and sending it to my vue js app, the number is sent as string. I even cast in the Model, the data to decimal but still does not work.
Do you have any idea what shoould i do?
I use Mysql 8.0 on local env
Level 53
@fredsparis that's because PHP doesn't have a decimal type so it's converted to string. You might try to cast it to a float instead.
2 likes
Please or to participate in this conversation.