fix endpoints

This commit is contained in:
root
2026-03-11 23:32:54 -04:00
parent 863e330dd8
commit 0f39dbee62
17 changed files with 2066 additions and 7 deletions
@@ -66,7 +66,7 @@ class StudentDirectoryService
'student_id' => $studentId,
'name' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
'age' => $student['age'] ?? 'N/A',
'email' => $emergencyInfo['emergency_contact_name'] ?? '',
'email' => $emergencyInfo['email'] ?? '',
'phone' => $emergencyInfo['cellphone'] ?? '',
'registration_grade' => $student['registration_grade'] ?? 'N/A',
'class_section_name' => $sectionDisplay !== '' ? $sectionDisplay : 'No class assigned',
@@ -161,4 +161,43 @@ class StudentDirectoryService
'school_year' => $schoolYear,
];
}
public function listStudents(?string $schoolYear = null): array
{
$context = $this->configService->context();
$selectedYear = $schoolYear ?: (string) ($context['school_year'] ?? '');
$students = Student::query()
->select([
'id',
'school_id',
'firstname',
'lastname',
'dob',
'age',
'gender',
'is_active',
'registration_grade',
'is_new',
'photo_consent',
'parent_id',
'registration_date',
'tuition_paid',
'rfid_tag',
'semester',
'year_of_registration',
'school_year',
])
->when($selectedYear !== '', fn ($q) => $q->where('school_year', $selectedYear))
->orderBy('lastname')
->orderBy('firstname')
->get()
->toArray();
return [
'students' => $students,
'schoolYear' => $selectedYear,
'currentYear' => (string) ($context['school_year'] ?? ''),
];
}
}