阅读(1825) (3)

Laravel 8 pipe() {#collection-method}

2021-07-01 15:42:02 更新

pipe 可以把集合放到回调参数中并返回回调的结果:

$collection = collect([1, 2, 3]);

$piped = $collection->pipe(function ($collection) {
    return $collection->sum();
});

// 6