From 3a5b4934f8eac896b6ca361b134538416e8eb8b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Oct 2023 20:47:34 +0700 Subject: [PATCH] Update: Fitur Chart Dashboard, Grafik Peminjaman dan Pengembalian --- app/Http/Controllers/HomeController.php | 24 +++++++++++++++++ resources/views/dashboard/index.blade.php | 32 +++++++++++------------ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 835d3b1..b780e45 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -20,4 +20,28 @@ class HomeController extends Controller return view('dashboard.index', $data); } + + public function generateChartData() + { + $months = []; + $exitData = []; + $enterData = []; + + $monthNames = [ + 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', + 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember' + ]; + + for ($i = 1; $i <= 12; $i++) { + $months[] = date("F", mktime(0, 0, 0, $i, 1)); + + $exitCount = \App\Models\asset_status::whereMonth('exit_at', $i)->count(); + $enterCount = \App\Models\asset_status::whereMonth('enter_at', $i)->count(); + + $exitData[] = $exitCount; + $enterData[] = $enterCount; + } + + return compact('months', 'exitData', 'enterData', 'monthNames'); + } } diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php index 61e1d9f..24c9f6e 100644 --- a/resources/views/dashboard/index.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -92,13 +92,10 @@ -
-
-
Grafik Peminjaman VS Pengembalian -
+
Grafik Peminjaman VS Pengembalian