diff --git a/routes/web.php b/routes/web.php index 2ff8b5b4..6c162e1e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -40,8 +40,22 @@ Route::get('/report/x1', function(){ }); Route::get('/report/x2', function(){ - $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'x2'); + $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x2_%')->where('is_cancel', false)->where('user_id', '!=', 1)->whereYear('created_at', 2020)->get(); + $months = $bookings->groupBy(function($item) { + return $item->created_at->format('Y-m'); + }); + foreach($months as $month => $bookings){ + echo "

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

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

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

"; + } + + } }); Route::get('/po-approval', function(){