diff --git a/routes/web.php b/routes/web.php index 3b32037e..93bf2cc7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -151,6 +151,7 @@ Route::get('/report', function(){ if(!$customers->has($marking)){ $customers->put($marking, collect([ 'cbm' => $cbm, + 'orders' => 1, 'packages' => $packingList->packages->sum('quantity') ])); @@ -158,6 +159,7 @@ Route::get('/report', function(){ } $customers[$marking]['cbm'] += $cbm; + $customers[$marking]['orders'] += 1; $customers[$marking]['packages'] += $packingList->packages->sum('quantity'); } } @@ -165,10 +167,12 @@ Route::get('/report', function(){ echo '

total cbm: '. $total . '

'; echo '

active customers: '. count($customers) . '



'; + $i = 1; foreach ($customers->sortByDesc(function($customer){ return $customer['cbm']; }) as $marking => $customer) { - echo ''.$marking.': '.$customer['cbm'].' CBM ( '.$customer['packages'].' ) CTNS

'; + echo ''.$i.'. '.$marking.': '.$customer['cbm'].' CBM ('. $customer['orders'] .' - '.$customer['packages'].' ) CTNS

'; + $i++; }