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 @@ -