Replies: 2 comments 1 reply
-
Hey. Try using the collection's $localData = Listings::with('people')
->where('email', $data['email'])
->get();
$groupedPeople = $localData->groupBy(fn (array $item) => $item['people']['area']); |
Beta Was this translation helpful? Give feedback.
1 reply
-
$grouped_people = $local_data->people->groupBy('area'); This is completely valid and works, no matter the columns of parent for the people relationship are. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have columns with the same name in both the parent table (Listings) and the related table (people), when i use groupBy it is using the 'area' column from the Parent rather than the relation, how can i get it to group by the relation 'area' column?
Any help will be very much appreciated.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions