feat: snapshot class_name di setiap presensi & pelanggaran
Migration: tambah kolom: - attendances.class_name (varchar 100) - violations.student_class (varchar 100) - Backfill data existing dari students.class_name Controller manual: simpan class_name dari form Sync E-Jurnal: simpan class_name dari lookup student ViolationService: ambil class_name dari student saat buat Model: tambah ke fillable Ini menjamin data historis tetap akurat meskipun siswa naik kelas (X→XI→XII) di tahun ajaran baru.
This commit is contained in:
@@ -51,9 +51,11 @@ class AttendanceSyncController extends Controller
|
||||
];
|
||||
|
||||
$sourceIds = array_unique(array_column($attendances, 'source_student_id'));
|
||||
$studentMap = Student::whereIn('source_id', $sourceIds)
|
||||
\$students = Student::whereIn('source_id', $sourceIds)
|
||||
->where('is_active', true)
|
||||
->pluck('id', 'source_id');
|
||||
->get(['id', 'source_id', 'class_name']);
|
||||
$studentMap = $students->pluck('id', 'source_id');
|
||||
$classNameMap = $students->pluck('class_name', 'id');
|
||||
|
||||
$alphaCounts = [];
|
||||
$alphaDate = null;
|
||||
@@ -88,6 +90,7 @@ class AttendanceSyncController extends Controller
|
||||
],
|
||||
[
|
||||
'status' => $localStatus,
|
||||
'class_name' => $classNameMap[$localStudentId] ?? null,
|
||||
'notes' => $item['notes'] ?? null,
|
||||
'recorded_by' => null,
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user