customer report

This commit is contained in:
omair saleh
2021-10-01 19:26:42 +08:00
parent 933f39d280
commit bf7443887c
+21 -5
View File
@@ -133,19 +133,35 @@ Route::get('/report', function(){
$containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get();
$total = 0;
$customers = [];
foreach ($containers as $container){
$cbm = $container->packingLists->sum(function($packing_list){
return $packing_list->packages->sum(function ($package){
foreach($container->packingLists as $packingList){
$cbm = $packingList->packages->sum(function ($package){
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100));
});
});
$total += $cbm;
$total += $cbm;
if(!array_key_exists($packingList->owner->id, $customers)){
$marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
$customers[$packingList->owner->id] = [
'marking' => $marking,
'cbm' => $cbm,
'packages' => $packingList->packages->sum('quantity')
];
echo $container->reference.': '.$cbm.'<br><br>';
continue;
}
$customers[$packingList->owner->id]['cbm'] += $cbm;
$customers[$packingList->owner->id]['packages'] += $packingList->packages->sum('quantity');
}
}
dd($customers);
echo '<br><br><br>total cbm: '. $total;
});