yusuf375
1 week ago
261
3
Laravel

Eloquent Relationship, Group By

Posted 1 week ago by yusuf375

i have a collection of same program_name but courses are different. i want to groupBy program_name but not working as i expected The collection like [ { "id": 1, "university_id": 1, "program_name": "Business School", "created_at": "2020-03-18 06:25:50", "updated_at": "2020-03-18 06:25:50", "course": [] }, { "id": 2, "university_id": 2, "program_name": "Business School", "created_at": "2020-03-18 06:25:54", "updated_at": "2020-03-18 06:25:54", "course": [] }, { "id": 3, "university_id": 3, "program_name": "Business School", "created_at": "2020-03-18 06:26:00", "updated_at": "2020-03-18 06:26:00", "course": [ {10 items}, {10 items} ] } ] i want like this { "program_name": "Business School", "course": [ {10 items}, {10 items} }

any help please?

Please sign in or create an account to participate in this conversation.