In this tutorial we will explain how to create custom collection array. what is laravel collection.
Laravel collection
Laravel collection all methods define by Illuminate\Support\Collection class. Laravel collection perform many operation like php array and it very fast compare to php array. Collection class allowed to chain of multiple operation on a collection object.
Creating laravel collection
Laravel provides a collect() helper method to create Illuminate\Support\Collection class instance for the given array.
$collection = collect(['black', 'red', 'white', 'yellow']); dd($collection); //it print a collection object of colors array
Read Also : Laravel nested relationship with eager loading