Laravel - Collections - Method Shift
The shift
method removes and returns the first item from the collection:
$collection = collect([1, 2, 3, 4, 5]);
$collection->shift();
// 1
$collection->all();
// [2, 3, 4, 5]
You may pass an integer to the shift
method to remove and return multiple items from the beginning of a collection:
$collection = collect([1, 2, 3, 4, 5]);
$collection->shift(3);
// collect([1, 2, 3])
$collection->all();
// [4, 5]