From 8484dea7dcfad1e7128f238ae91f21f1ec360cde Mon Sep 17 00:00:00 2001 From: Diandaru Date: Thu, 19 Dec 2024 11:16:56 +0700 Subject: [PATCH] filter+sidebar --- .../Controllers/DashboardRplController.php | 1 + app/Http/Controllers/SiswaController.php | 13 +- .../views/components/app/navbar.blade.php | 18 +- .../views/components/app/sidebar.blade.php | 113 +++---- resources/views/dashboard_siswa.blade.php | 2 +- resources/views/dashboardrpl.blade.php | 2 +- .../views/monitoring_siswa/siswa.blade.php | 277 ++++++++++-------- 7 files changed, 244 insertions(+), 182 deletions(-) diff --git a/app/Http/Controllers/DashboardRplController.php b/app/Http/Controllers/DashboardRplController.php index 88ab172..df1f523 100644 --- a/app/Http/Controllers/DashboardRplController.php +++ b/app/Http/Controllers/DashboardRplController.php @@ -5,6 +5,7 @@ use App\Models\Siswa; use Carbon\Carbon; use Illuminate\Http\Request; +use App\Models\Materi; use Illuminate\Support\Facades\Auth; class DashboardRplController extends Controller diff --git a/app/Http/Controllers/SiswaController.php b/app/Http/Controllers/SiswaController.php index 1e2fa06..5197d89 100644 --- a/app/Http/Controllers/SiswaController.php +++ b/app/Http/Controllers/SiswaController.php @@ -14,14 +14,23 @@ class SiswaController extends Controller public function index(Request $request) { $statusFilter = $request->get('status', 'all'); + $kategoriFilter = $request->get('kategori', 'all'); // Default 'all' $userId = Auth::id(); + // Query dasar untuk data siswa $siswaQuery = Siswa::where('user_id', $userId); + // Filter status jika tidak "all" if ($statusFilter !== 'all') { $siswaQuery->where('status', $statusFilter); } + // Filter kategori jika tidak "all" + if ($kategoriFilter !== 'all') { + $siswaQuery->where('kategori', $kategoriFilter); + } + + // Proses data siswa dan hitung total waktu $siswa = $siswaQuery->orderBy('created_at', 'desc')->get()->map(function ($item) { if ($item->waktu_mulai && $item->waktu_selesai) { $waktuMulai = Carbon::parse($item->waktu_mulai); @@ -38,7 +47,7 @@ public function index(Request $request) $aktivitas = Aktivitas::all(); $materitkj = Materi::where('jurusan', 'TKJ')->get(); - return view('monitoring_siswa.siswa', compact('siswa', 'materitkj', 'aktivitas', 'statusFilter')); + return view('monitoring_siswa.siswa', compact('siswa', 'materitkj', 'aktivitas', 'statusFilter', 'kategoriFilter')); } public function updateTime(Request $request, $id) @@ -67,7 +76,7 @@ public function updateTime(Request $request, $id) } $currentDate = Carbon::parse($item->waktu_mulai)->format('Y-m-d'); - $newWaktuSelesai = $currentDate.' '.$request->waktu_selesai; + $newWaktuSelesai = $currentDate . ' ' . $request->waktu_selesai; $item->update([ 'waktu_selesai' => $newWaktuSelesai, diff --git a/resources/views/components/app/navbar.blade.php b/resources/views/components/app/navbar.blade.php index 511fbcd..8aca4e9 100644 --- a/resources/views/components/app/navbar.blade.php +++ b/resources/views/components/app/navbar.blade.php @@ -8,12 +8,22 @@
Dashboard