Laravel - Collections - Method Every
The every
method may be used to verify that all elements of a collection pass a given truth test:
collect([1, 2, 3, 4])->every(function ($value, $key) {
return $value > 2;
});
// false
If the collection is empty, the every
method will return true:
$collection = collect([]);
$collection->every(function ($value, $key) {
return $value > 2;
});
// true