Reputation: 1
I use the following command to output in Laravel :
response()->json($data, $status, [])->send();
it has been converting all the numbers that are numerically defined in the database into strings Using the following value solves this problem, but this solution converts all numbers into numeric types
response()->json($data, $status, [], JSON_NUMERIC_CHECK)->send();
And I do not want this to happen because there are numbers in the database that are from the string and should remain the string.
What should be done to display all values of their type in the output?
Upvotes: 0
Views: 1305
Reputation: 106
Yep, as Jairo Nava said;
In your model
protected $casts = [
'your_int_field' => 'integer',
];
With a correct INT sql field.
Upvotes: 1