1

Bear in mind that Eloquent collections don’t behave like normal Collections, ie. they use getKey to merge results, so Model::all()->merge(Model::all())->count() === Model::all()->count()

– eithed

Mar 11, 2020 at 16:47

 

be aware that The merge method will replace any first collection in the original second collection’s items if a string key with the same value exists in the supplied $items. If the first collection keys are numeric, the second collection will be added to the end of the new collection’s laravel.com/docs/8.x/collections#method-merge

– shintaroid

Feb 4, 2021 at 8:19

 

I think removing duplicates is required.

– mercury

Feb 24, 2022 at 20:59

You May Also Like

More From Author

+ There are no comments

Add yours