diff --git a/app/Http/Controllers/Admin/ViolationReportController.php b/app/Http/Controllers/Admin/ViolationReportController.php index fcb23d1..4853be8 100644 --- a/app/Http/Controllers/Admin/ViolationReportController.php +++ b/app/Http/Controllers/Admin/ViolationReportController.php @@ -63,9 +63,9 @@ class ViolationReportController extends Controller ->sortByDesc('jumlah') ->values(); - $perKelas = $violations->groupBy(fn ($v) => $v->student?->class?->name ?? 'Tanpa Kelas') + $perKelas = $violations->groupBy(fn ($v) => $v->student_class ?: ($v->student?->class?->name ?? 'Tanpa Kelas')) ->map(fn ($group) => [ - 'kelas' => $group->first()->student?->class?->name ?? 'Tanpa Kelas', + 'kelas' => $group->first()->student_class ?: ($group->first()->student?->class?->name ?? 'Tanpa Kelas'), 'jumlah' => $group->count(), 'poin' => $group->sum('points'), ]) @@ -161,9 +161,9 @@ class ViolationReportController extends Controller ->sortByDesc('jumlah') ->values(); - $perKelas = $rows->groupBy(fn ($v) => $v->student?->class?->name ?? 'Tanpa Kelas') + $perKelas = $rows->groupBy(fn ($v) => $v->student_class ?: ($v->student?->class?->name ?? 'Tanpa Kelas')) ->map(fn ($group) => [ - 'kelas' => $group->first()->student?->class?->name ?? 'Tanpa Kelas', + 'kelas' => $group->first()->student_class ?: ($group->first()->student?->class?->name ?? 'Tanpa Kelas'), 'jumlah' => $group->count(), 'poin' => $group->sum('points'), ]) diff --git a/resources/views/reports/violation-report-pdf.blade.php b/resources/views/reports/violation-report-pdf.blade.php index b11be29..a7e28ce 100644 --- a/resources/views/reports/violation-report-pdf.blade.php +++ b/resources/views/reports/violation-report-pdf.blade.php @@ -159,7 +159,7 @@ {{ $v->violation_date?->format('d/m/Y') }} {{ $v->student?->nisn }} {{ $v->student?->full_name }} - {{ $v->student?->class?->name }} + {{ $v->student_class ?: $v->student?->class?->name }}
{{ $v->violationType?->name }} ({{ $v->violationType?->category?->name ?? '-' }})
@if ($v->description)