update api and add more features

This commit is contained in:
root
2026-06-04 02:24:41 -04:00
parent fa6c9519a0
commit 4e33882ac7
131 changed files with 34596 additions and 340 deletions
@@ -74,6 +74,7 @@ class ParentRegistrationService
}
$createdStudentIds = [];
$skippedStudents = [];
DB::transaction(function () use (
$parentId,
@@ -81,17 +82,28 @@ class ParentRegistrationService
$emergencyContacts,
$schoolYear,
$semester,
&$createdStudentIds
&$createdStudentIds,
&$skippedStudents
) {
foreach ($students as $student) {
// Duplicate check is scoped to THIS parent: one family's
// legitimately registered child must not block another family
// from registering a child with the same name and DOB.
$exists = Student::query()
->where('parent_id', $parentId)
->where('school_year', $schoolYear)
->where('dob', $student['dob'])
->where('firstname', $student['firstname'])
->where('lastname', $student['lastname'])
->whereRaw('LOWER(TRIM(firstname)) = ?', [strtolower(trim((string) $student['firstname']))])
->whereRaw('LOWER(TRIM(lastname)) = ?', [strtolower(trim((string) $student['lastname']))])
->first();
if ($exists) {
$skippedStudents[] = [
'firstname' => $student['firstname'],
'lastname' => $student['lastname'],
'dob' => $student['dob'],
'reason' => 'already_registered',
];
continue;
}
@@ -153,6 +165,7 @@ class ParentRegistrationService
return [
'created_student_ids' => $createdStudentIds,
'skipped' => $skippedStudents,
];
}