Joined April 2012
·
Posted to
Adding Items to Laravel 4 Collections
over 1 year
ago
Hi there. On Laravel 4.1 this doesn't really seem to work?
I get an exception
Call to undefined method Illuminate\Database\Query\Builder::merge()
and if I add ->get() to the first two lines (to actually receive a Collection for each model) then the resulting merged Collection is unique on the array keys (thus returning only one entry per id = 1 for instance)... Can you confirm?
Achievements
28 Karma
0 Total ProTip Views

Charity
Fork and commit to someone's open source project in need

Forked
Have a project valued enough to be forked by someone else

Nephila Komaci
Have at least one original repos where PHP is the dominant language
Agreed. Thanks for the follow-up.
Not sure if this may help, but In the end what I ended up doing is to create and return a Eloquent\Collection object to which I'm adding the various models manually (using $newCollection->add() ) .
That works, the only caveat being to reset the array keys before returning with a $newCollection->values() call.