diff --git a/app/Http/Controllers/DashboardRplController.php b/app/Http/Controllers/DashboardRplController.php index 396014c..91e708c 100644 --- a/app/Http/Controllers/DashboardRplController.php +++ b/app/Http/Controllers/DashboardRplController.php @@ -101,7 +101,6 @@ public function index(Request $request) ], ]; - $siswaDataLearning = Siswa::where('user_id', $userId) ->where('kategori', 'Learning') ->get() @@ -111,12 +110,15 @@ public function index(Request $request) if ($item->waktu_mulai && $item->waktu_selesai) { $waktuMulai = Carbon::parse($item->waktu_mulai); $waktuSelesai = Carbon::parse($item->waktu_selesai); + return $waktuSelesai->greaterThan($waktuMulai) ? $waktuSelesai->diffInSeconds($waktuMulai) : 0; } + return 0; }); $percentage = $totalWaktuLearning ? ($totalTime / $totalWaktuLearning) * 100 : 0; + return ['totalTime' => $totalTime, 'percentage' => $percentage]; }); @@ -126,11 +128,10 @@ public function index(Request $request) [ 'data' => $siswaDataLearning->pluck('percentage')->values(), 'backgroundColor' => ['#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0', '#9966FF'], - ] - ] + ], + ], ]; - $activityData = $jumlahAktivitasLearning; return view('dashboardrpl', compact(