Laravel 8 eachSpread() {#collection-method}
eachSpread 方法用于循环集合项,将每个嵌套集合项的值传递给回调函数:
$collection = collect([['John Doe', 35], ['Jane Doe', 33]]);
$collection->eachSpread(function ($name, $age) {
//
});你可以通过在回调函数里返回 false 来中断循环:
$collection->eachSpread(function ($name, $age) {
return false;
});