Laravel - Collections - Method Each

The each method iterates over the items in the collection and passes each item to a closure:

    
    $collection->each(function ($item, $key) {
        //
    });
	

If you would like to stop iterating through the items, you may return false from your closure:

    
    $collection->each(function ($item, $key) {
        if (/* condition */) {
            return false;
        }
    });