Append a Laravel collection with another collection

For versions < 5.4 you can merge the two eloquent collections by resetting keys with toBase like this:

$mergedCollection = $entries->toBase()->merge($posts);

For versions >= 5.4 you can use concat as suggested by Jason.


Here's the link: laravel7.X

$collection = collect(['Desk', 'Chair']);

$merged = $collection->merge(['Bookcase', 'Door']);

$merged->all();

I believe you may be looking for concat(). This will append one container to the end of another container, regardless of the keys of either.

$mergedCollection = $entries->concat($posts);