Laravel 8 pipe() {#collection-method}
pipe
可以把集合放到回调参数中并返回回调的结果:
$collection = collect([1, 2, 3]);
$piped = $collection->pipe(function ($collection) {
return $collection->sum();
});
// 6
pipe
可以把集合放到回调参数中并返回回调的结果:
$collection = collect([1, 2, 3]);
$piped = $collection->pipe(function ($collection) {
return $collection->sum();
});
// 6