I do have an Eloquent query which kinda looks like this:
DB::table('football')->orderBy('team_name', 'asc')->groupBy('team_id', 'team_name', 'info')->get(['team_id', 'team_name', 'info']);
This statement returns me only distinct values of the combination of those 3 columns.
The returned Eloquent collection object has the following structure:
[
{"team_id": "2000", "team_name": "FC Barcelona", "info": "03"},
{"team_id": "2000", "team_name": "FC Barcelona", "info": "09"},
{"team_id": "2000", "team_name": "FC Barcelona", "info": "D3"}
{"team_id": "3000", "team_name": "FC Chelsea", "info": "03"},
{"team_id": "3000", "team_name": "FC Chelsea", "info": "12"},
{"team_id": "4000", "team_name": "Real Madrid", "info": "06"}
]
is there a way in Eloquent or PHP to convert the above structure into the following:
[
{"team_id": "2000", "team_name": "FC Barcelona", "info": { "03", "09", "D3" } },
{"team_id": "3000", "team_name": "FC Chelsea", "info": { "03", "12" } },
{"team_id": "4000", "team_name": "Real Madrid", "info": { "06" } }
]
Thank you for your time and all the answers.