In this quick example, let’s see laravel collection merge example. Here you will learn laravel collection merge by value. In this article, we will implement a laravel eloquent merge collections. you will learn eloquent merge collections.
I will explain you step by step example how to user merge collection in laravel. i will also give you example how to merge collection with unique in laravel 6 and laravel 7. i will also give you example of how to merge two eloquent laravel collection.
So, let’s see bellow example.
Example 1:
public function index(){ $firstCollection = collect(['One', 'Two', 'Three']); $secondCollection = collect(['Four', 'Five']); $mergedCollection = $firstCollection->merge($secondCollection); $mergedCollection->all(); dd($mergedCollection);}
I hope it can help you…