I've recently started using Laravel 5 and the new Eloquent 5.* and I'm experiencing some unwanted results.
Previously in Laravel 4 when I did a call like:
Offer::find(1);
I would receive a response like:
{
"id": 1,
"loyalty_program_id": 1,
"name": "$5 OFF Your Service",
"points": 0,
"created_at": "2015-07-02 12:51:55",
"updated_at": "2015-07-02 12:51:55",
"deleted_at": null
}
Now in Laravel 5:
Offer::find(1);
// or even
DB::select('select * from offers where id=?', [1]);
Gives me the response:
{
"id": 1,
"0": 1,
"loyalty_program_id": 1,
"1": 1,
"name": "FREE Minifigure",
"2": "FREE Minifigure",
"points": 0,
"3": 0,
"created_at": "2015-07-09 15:40:13",
"4": "2015-07-09 15:40:13",
"updated_at": "2015-08-18 11:44:33",
"5": "2015-08-18 11:44:33",
"deleted_at": null,
"6": null
}
Can some explain to me why the column position is showing up as a property on the object? Is there a configuration option to remove this functionalty?
I've tried searching all over the web and I can't even find why they included this in their release.
Example response
$app->get('test/route', function() use ($app){
return response()->json(\App\Models\Offer::find(442));
});
Thanks
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community