I'm executing a query like this as well as some others and returning them via response()->json().
$transactions = Transaction::where('created_at', '>=',
now()->firstOfYear())->get()->groupBy(function ($transaction)
{
return Carbon::parse($transaction->created_at)->format('M');
});
return response()->json([
'user' => $user->toArray(),
'transactions' => $transactions->toArray()
]);
However, while transactions is an Array in php, when it goes through response()->json it gets turned into an Object. I was hoping someone could tell me how I can prevent this and keep it as an array so I can iterate over it?
Thanks.
Picture of transactions output as requested. (Had to blur a lot of stuff due to sensitive info.)

var_dumpof$user->toArray()and show us the output. Is it an associative array? If so, javascript does not have associative arrays andjson_encodewill output it as an object.