Laravel - Collections - Method Mapspread

The mapSpread method iterates over the collection's items, passing each nested item value into the given closure. The closure is free to modify the item and return it, thus forming a new collection of modified items:

    
    $collection = collect([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
    
    $chunks = $collection->chunk(2);
    
    $sequence = $chunks->mapSpread(function ($even, $odd) {
        return $even + $odd;
    });
    
    $sequence->all();
    
    // [1, 5, 9, 13, 17]