Search

Laravel Collection Static API: make

November 30, 2016 —John Koster

make($items = [])

The make static method creates a new instance of a collection with the provided $items (assuming that the provided $items is in itself not an instance of Collection). The following code sample highlights the usage of the make static method:

1<?php
2 
3use Illuminate\Support\Collection;
4 
5$items = [
6 'sea' => 'Mosasaurus',
7 'air' => 'Argentavis magnificens',
8 'land' => 'Dusicyon australis'
9];
10 
11$collection = Collection::make($items);
12 
13// true
14$isCollection = $collection instanceof Collection;