diff --git a/routes/web.php b/routes/web.php
index b0976c5c..29757f4b 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -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.'
';
+ continue;
+ }
+
+ $customers[$packingList->owner->id]['cbm'] += $cbm;
+ $customers[$packingList->owner->id]['packages'] += $packingList->packages->sum('quantity');
+ }
}
+ dd($customers);
+
echo '
total cbm: '. $total;
+
+
});