From 16aa8f5f995144d33416e2e8d6fb7464607e1f77 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 9 Jan 2021 10:56:22 +0800 Subject: [PATCH] show active customers in the report --- routes/web.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 9cee16cf..99d49d29 100644 --- a/routes/web.php +++ b/routes/web.php @@ -23,7 +23,6 @@ Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('p Route::group(['middleware' => ['role:admin']], function() { Route::get('/report/x1', function(){ - $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x1_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get(); $months = $bookings->groupBy(function($item) { return $item->created_at->format('Y-m'); @@ -31,6 +30,9 @@ Route::group(['middleware' => ['role:admin']], function() { foreach($months as $month => $bookings){ echo "

".Carbon::parse($month)->format('m-Y').": ".$bookings->sum('bia')." MYR

"; + echo "

Active Customers: ".count($bookings->groupBy(function($item){ + return $item->user_id; + }))." MYR

"; $days = $bookings->groupBy(function($item){ return $item->created_at->format('Y-m-d'); });