collect laravel function code example
Example 1: add to collection laravel
$item = collect();
$item->push($product);
Example 2: laravel collection methods
$collection = collect([1,2,3,4]);
$collection->each(function($item){
return $item*$item;
});
// [1,4,9,16]
Example 3: collection methods laravel
$collection->each(function ($item, $key) {
hj
});