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

1 min read

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).


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;


There are no comments. Be the first to comment!

Up next