I'm writing an api and attempting to convert a number of results into JSON. When the eloquent result is converted to an array, I am expecting something like this:
[
{
"id": "0", ...
},
{
"id": "", ...
},
]
but instead, Laravel displays it as a key, value list using the table key:
"0":{
{
"id": "0", ...
}
},
"1":{
{
"id": "1", ...
}
}
Here is the function:
$results = \App\Event::with('sandboxes')->get()->sortBy('start_time')->forPage($pageNum,$perPage);
return response()->json(array(
"events" => $page,
));
How can I get Laravel to give me a proper array?