feat: update student import and graduation workflows

This commit is contained in:
2026-04-30 00:04:52 +07:00
parent 189b076ab0
commit ac22f8b7c8
51 changed files with 4547 additions and 1287 deletions
@@ -16,7 +16,17 @@ class StudentSyncController extends Controller
abort_unless(collect($token->abilities ?? [])->contains('students'), 403, 'Token tidak memiliki akses ke data siswa.');
$classLevel = strtoupper(trim((string) $request->query('class_level', '')));
$items = Student::query()
->when(in_array($classLevel, ['X', 'XI', 'XII'], true), function ($query) use ($classLevel) {
$query->whereHas('classRoom', fn ($classQuery) => $classQuery->where('level', $classLevel));
})
->with([
'academicYear:id,name,start_year,end_year,is_active',
'department:id,code,name,description,is_active',
'classRoom:id,academic_year_id,department_id,name,level,is_active',
])
->orderBy('full_name')
->get([
'id',
@@ -24,16 +34,74 @@ class StudentSyncController extends Controller
'nisn',
'full_name',
'gender',
'place_of_birth',
'date_of_birth',
'nationality',
'address',
'postal_code',
'academic_year_id',
'department_id',
'class_id',
'entry_date',
'status',
'phone_number',
'email',
'photo_path',
'notes',
'updated_at',
]);
])
->map(function (Student $student) {
return [
'id' => $student->id,
'student_number' => $student->student_number,
'nisn' => $student->nisn,
'full_name' => $student->full_name,
'gender' => $student->gender,
'place_of_birth' => $student->place_of_birth,
'date_of_birth' => $student->date_of_birth?->toDateString(),
'nationality' => $student->nationality,
'address' => $student->address,
'postal_code' => $student->postal_code,
'academic_year_id' => $student->academic_year_id,
'academic_year_name' => $student->academicYear?->name,
'academic_year' => $student->academicYear ? [
'id' => $student->academicYear->id,
'name' => $student->academicYear->name,
'start_year' => $student->academicYear->start_year,
'end_year' => $student->academicYear->end_year,
'is_active' => (bool) $student->academicYear->is_active,
] : null,
'department_id' => $student->department_id,
'department_code' => $student->department?->code,
'department_name' => $student->department?->name,
'department' => $student->department ? [
'id' => $student->department->id,
'code' => $student->department->code,
'name' => $student->department->name,
'description' => $student->department->description,
'is_active' => (bool) $student->department->is_active,
] : null,
'class_id' => $student->class_id,
'class_name' => $student->classRoom?->name,
'class_level' => $student->classRoom?->level,
'classroom' => $student->classRoom ? [
'id' => $student->classRoom->id,
'name' => $student->classRoom->name,
'level' => $student->classRoom->level,
'academic_year_id' => $student->classRoom->academic_year_id,
'department_id' => $student->classRoom->department_id,
'is_active' => (bool) $student->classRoom->is_active,
] : null,
'entry_date' => $student->entry_date?->toDateString(),
'status' => $student->status,
'phone_number' => $student->phone_number,
'email' => $student->email,
'photo_path' => $student->photo_path,
'notes' => $student->notes,
'updated_at' => $student->updated_at?->toISOString(),
];
})
->values();
return response()->json([
'success' => true,