columna de matriz de suma de colección de laravel
$collection = collect([
['name' => 'JavaScript: The Good Parts', 'pages' => 176, 'price' => 100.00],
['name' => 'JavaScript: The Definitive Guide', 'pages' => 314, 'price' => 150.00]
]);
$result = $collection->pipe(function ($collection) {
return collect([
'total_pages' => $collection->sum('pages'),
'total_price' => $collection->sum('price'),
]);
});
Shadow