Joined April 2012
·

Pierluigi Cau

Booksteady
·
Rome
·
·
·

Posted to Adding Items to Laravel 4 Collections over 1 year ago

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.

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