Laravel - Collections - Method Prepend

The prepend method adds an item to the beginning of the collection:

    
    $collection = collect([1, 2, 3, 4, 5]);
    
    $collection->prepend(0);
    
    $collection->all();
    
    // [0, 1, 2, 3, 4, 5]
	

You may also pass a second argument to specify the key of the prepended item:

    
    $collection = collect(['one' => 1, 'two' => 2]);
    
    $collection->prepend(0, 'zero');
    
    $collection->all();
    
    // ['zero' => 0, 'one' => 1, 'two' => 2]