diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 78d400b..c157cb6 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -159,135 +159,5 @@ class DashboardController extends Controller return view('Admin.dashboard', compact('customerCount','restaurantCount','dataMonthlyWithType3','dataMonthlyWithType4','dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4','formattedDefaultData','quarterlyData')); } - // public function showDashboard() - // { - - - // // Fetching data for sorting by day - // // $dailyData = OrderedPassport::select(DB::raw("COUNT(*) as count"), DB::raw("DATE(created_at) as date")) - // // ->whereBetween('created_at', [now()->subDays(7), now()]) // Fetch data for the last 7 days - // // ->groupBy(DB::raw("DATE(created_at)")) - // // ->orderBy(DB::raw("DATE(created_at)")) - // // ->pluck('count', 'date') - // // ->toArray(); - - // // Ensure that $dailyData contains zeros for days with no data - // $start_date = now()->subDays(7)->startOfDay(); - // $end_date = now()->endOfDay(); - // $formattedDailyData = []; - // while ($start_date <= $end_date) { - // $formattedDailyData[$start_date->format('Y-m-d')] = isset($dailyData[$start_date->format('Y-m-d')]) ? $dailyData[$start_date->format('Y-m-d')] : 0; - // $start_date->addDay(); - // } - - // // Default sales chart data (monthly) - // // $defaultData = OrderedPassport::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - // // ->whereYear('created_at', date('Y')) - // // ->groupBy(DB::raw("MONTH(created_at)")) - // // ->orderBy(DB::raw("MONTH(created_at)")) - // // ->pluck('count', 'month') - // // ->toArray(); - - // // Ensure that $defaultData contains zeros for months with no data - // $months = range(1, 12); - // $formattedDefaultData = []; - // foreach ($months as $month) { - // $formattedDefaultData[$month] = isset($defaultData[$month]) ? $defaultData[$month] : 0; - // } - - // // $quarterlyData = OrderedPassport::select( - // // DB::raw("COUNT(*) as count"), - // // DB::raw("QUARTER(created_at) as quarter") - // // ) - // // ->whereYear('created_at', date('Y')) - // // ->groupBy(DB::raw("QUARTER(created_at)")) - // // ->orderBy(DB::raw("QUARTER(created_at)")) - // // ->pluck('count', 'quarter') - // // ->toArray(); - - // // Ensure that $quarterlyData contains zeros for quarters with no data - // for ($i = 1; $i <= 4; $i++) { - // if (!isset($quarterlyData[$i])) { - // $quarterlyData[$i] = 0; - // } - // } - - // // Fetching data for yearly option - // // $yearlyData = OrderedPassport::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - // // ->groupBy(DB::raw("YEAR(created_at)")) - // // ->pluck('count', 'year') - // // ->toArray(); - // // - // // Monthly data - // $dataMonthlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - // ->whereIn('principal_type_xid', [3]) - // ->whereYear('created_at', date('Y')) - // ->groupBy(DB::raw("MONTH(created_at)")) - // ->orderBy(DB::raw("MONTH(created_at)")) - // ->pluck('count', 'month') - // ->toArray(); - - // $dataMonthlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) - // ->whereIn('principal_type_xid', [4]) - // ->whereYear('created_at', date('Y')) - // ->groupBy(DB::raw("MONTH(created_at)")) - // ->orderBy(DB::raw("MONTH(created_at)")) - // ->pluck('count', 'month') - // ->toArray(); - - // // Quarterly data - // $dataQuarterlyWithType3 = IamPrincipal::select( - // DB::raw("COUNT(*) as count"), - // DB::raw("QUARTER(created_at) as quarter") - // ) - // ->whereIn('principal_type_xid', [3]) - // ->groupBy(DB::raw("QUARTER(created_at)")) - // ->orderBy(DB::raw("QUARTER(created_at)")) - // ->pluck('count', 'quarter') - // ->toArray(); - // for ($i = 1; $i <= 4; $i++) { - // if (!isset($dataQuarterlyWithType3[$i])) { - // $dataQuarterlyWithType3[$i] = 0; - // } - // } - - // $dataQuarterlyWithType4 = IamPrincipal::select( - // DB::raw("COUNT(*) as count"), - // DB::raw("QUARTER(created_at) as quarter") - // ) - // ->whereIn('principal_type_xid', [4]) - // ->groupBy(DB::raw("QUARTER(created_at)")) - // ->orderBy(DB::raw("QUARTER(created_at)")) - // ->pluck('count', 'quarter') - // ->toArray(); - // for ($i = 1; $i <= 4; $i++) { - // if (!isset($dataQuarterlyWithType4[$i])) { - // $dataQuarterlyWithType4[$i] = 0; - // } - // } - - // // Yearly data - // $dataYearlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - // ->whereIn('principal_type_xid', [3]) - // ->groupBy(DB::raw("YEAR(created_at)")) - // ->pluck('count', 'year') - // ->toArray(); - // // dd($dataYearlyWithType3); - - // $dataYearlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) - // ->whereIn('principal_type_xid', [4]) - // ->groupBy(DB::raw("YEAR(created_at)")) - // ->pluck('count', 'year') - // ->toArray(); - - - // $customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count(); - // // $activePassports = ManagePassport::where('is_active', 1)->take(12)->get(); - // // $restaurantCount = MyPassportVoucher::where('is_redeem', 1)->count(); - // // $recent_transaction = OrderedPassport::with('order', 'order_passport', 'carts.passport', 'iamPrincipal')->get()->toArray(); - // // $datas = MyPassportVoucher::with('passportVouchers', 'passportData', 'customer')->get()->toArray(); - - // // Pass the data to the view - // return view('Admin.dashboard', compact('customerCount', '', 'restaurantCount', '', 'datas', 'formattedDefaultData', 'quarterlyData', 'yearlyData', 'dataMonthlyWithType3', 'dataMonthlyWithType4', 'dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4','formattedDailyData')); - // } + } diff --git a/resources/views/Admin/dashboard.blade.php b/resources/views/Admin/dashboard.blade.php index 7433641..8cf4625 100644 --- a/resources/views/Admin/dashboard.blade.php +++ b/resources/views/Admin/dashboard.blade.php @@ -59,7 +59,7 @@ -