container monthly report

This commit is contained in:
omair saleh
2021-10-01 18:14:46 +08:00
parent 9221bd094c
commit 96d701bc80
+10 -5
View File
@@ -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;
});