Feb 20, 2018
3
Level 7
decimal or integer columns are returned as strings
Hello!
Well as the title states, I'm having problem with this, since in my migration table I have:
$table->decimal('price');
$table->integer('users');
$table->integer('storage');
The returned response looks like this:
[{"animals":"5","created_at":"2018-02-20 17:54:25","emails":"92","period":"8","price":"9","sms":"72","storage":"1430""users":"6"}].
I don't know what I'm doing wrong, if I set any of the into the casts property of the model, it works, but I think it should work without casting them... doesn't it?
Level 67
Sorry, not sure for sqlite. It's a PDO issue. Taylor said to use casts. https://github.com/laravel/framework/issues/3548
Not sure why PDO does this in the first place. It's stupid. You shouldn't have to cast things. You should get the data exactly as it's stored.
1 like
Please or to participate in this conversation.