How to merge two Laravel collections, putting one behind the other, merged into a single collection

Indeed, the method you are looking for is concat().

With concat() you add the elements of one collection, no matter what they are, to those of the other collection.

$firstCollection = collect(); $secondCollection = collect(); $add = $firstCollection->concat($secondCollection);

The collection resulting from this operation ($sum) would be:

It just added the elements at the end, without dealing with possible duplicates.

See also  Scope in Angular, handling scopes with $parent
Loading Facebook Comments ...
Loading Disqus Comments ...