diff --git a/routes/web.php b/routes/web.php index 29de21f6..f4e8e837 100644 --- a/routes/web.php +++ b/routes/web.php @@ -132,15 +132,20 @@ Route::group(['prefix' => 'template', 'as' => 'template.'], function () { Route::get('/report', function(){ $containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get(); - dd(count($containers)); - $totalCbm = $containers->sum(function($container){ - return $container->packingLists->sum(function($packing_list){ + $total = 0; + + foreach ($containers as $container){ + $cbm = $container->packingLists->sum(function($packing_list){ return $packing_list->packages->sum(function ($package){ return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)); }); }); - }); - echo 'total cbm: '. $totalCbm; + $total += $cbm; + + echo $container->reference.': '.$cbm; + } + + echo 'total cbm: '. $total; });