From 27e1e71fc9dbf007f4d579b350fc0f1a693a355e Mon Sep 17 00:00:00 2001 From: Novy San87 Date: Thu, 6 Aug 2026 23:04:19 +0700 Subject: [PATCH] fix: Export Excel kini mengikuti semua filter (periode, kelas, jenis pelanggaran) + scope wali kelas --- .../Controllers/Admin/ViolationExportController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Http/Controllers/Admin/ViolationExportController.php b/app/Http/Controllers/Admin/ViolationExportController.php index 6672b2f..4619b36 100644 --- a/app/Http/Controllers/Admin/ViolationExportController.php +++ b/app/Http/Controllers/Admin/ViolationExportController.php @@ -26,6 +26,16 @@ class ViolationExportController extends Controller if ($request->filled('date_to')) { $query->whereDate('violation_date', '<=', $request->date_to); } + if ($request->filled('class_id')) { + $query->whereHas('student', fn ($q) => $q->where('class_id', $request->class_id)); + } + if ($request->filled('violation_type_id')) { + $query->where('violation_type_id', $request->violation_type_id); + } + // Wali kelas hanya melihat data kelasnya sendiri + if (auth()->user() && auth()->user()->isScopedWaliKelas()) { + $query->whereHas('student', fn ($q) => $q->whereIn('class_id', auth()->user()->homeroomClassIds())); + } $violations = $query->orderBy('violation_date', 'desc')->get();