Laravel 5 Collections Static API: Creating a New Collection Instance From Arrays Using make

April 22, 2018 —John Koster

The make static method creates a new instance of a collection with the provided $items (assuming that the provided $items argument is not already a collection instance).

#Signature

1public static function make(
2 $items = []
3);

#Example Use

The following code sample highlights the usage of the make static method:

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

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.