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

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

Laravel 5

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

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

Example Use

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

use Illuminate\Support\Collection;

$items = [
    'sea'  => 'Mosasaurus',
    'air'  => 'Argentavis magnificens',
    'land' => 'Dusicyon australis'
];

$collection = Collection::make($items);

// true
$isCollection = $collection instanceof Collection;

Start the Discussion

Leave a comment

Subscribe to our newsletter