Mar 23, 2017
0
Level 5
Variables casts as string instead of numbers
Hey,
I have a simple db table with some tinyints and integers. In a vue component I do some checks and calculations on the integers.
On my machine (chrome on osx) everything works fine. If I deploy the code on the server the integers are casted as strings, so my checks and additions won't work anymore.
Examples:
DB:
job.amount = 100
job.is_printed = 0
On the server
Vue:
return job.is_printed; // return true. In the chrome vue devtool it says job.is_printed = "0"
On the osx machine:
Vue:
return job.is_printed; // return false. In the chrome vue devtool it says job.is_printed = 0
Same on calculations
On the server
Vue:
return _.sumBy(jobs, 'amount'); // 100200300
It simply connects the strings.
On the osx machine:
Vue:
return _.sumBy(jobs, 'amount'); // 600
When I explicit use the laravel casting in the model, it works on both machines.
But I want to know, why this is different on the machines?
Bye
Please or to participate in this conversation.