Skip to content
Advertisement

Get the two different objects together

I’ve got $campus_groups coming from CampusGroup

JavaScript

which has

JavaScript

and $campus_org_groups coming from CampusOrganizationGroup

JavaScript

which has

JavaScript

and would like to get both together like this (the important key is group_id and I’m ok if campus_organization_id is left out)

JavaScript

If I merge them

JavaScript

this is what I’m getting

JavaScript

If I union them

JavaScript

this is what I’m getting

JavaScript

Advertisement

Answer

I’ve changed

JavaScript

to

JavaScript

Notice the usage of collect() and also specification of the fields I really wanted (leaving out campus_organization_id). Then, the initial merge

JavaScript

would return the desired output

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement