add test batches
This commit is contained in:
@@ -16,15 +16,15 @@ class AttendanceParentLookupService
|
||||
->where('s.id', $studentId)
|
||||
->first();
|
||||
|
||||
if (! $row || empty($row->user_id)) {
|
||||
if (!$row || empty($row->user_id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'user_id' => (int) $row->user_id,
|
||||
'email' => (string) ($row->email ?? ''),
|
||||
'user_id' => (int) $row->user_id,
|
||||
'email' => (string) ($row->email ?? ''),
|
||||
'parent_name' => (string) ($row->parent_name ?? ''),
|
||||
'phone' => $row->cellphone ?? null,
|
||||
'phone' => $row->cellphone ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ class AttendanceParentLookupService
|
||||
->where('id', $studentId)
|
||||
->first();
|
||||
|
||||
if (! $stu) {
|
||||
if (!$stu) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$primaryId = (int) ($stu->parent_id ?? 0);
|
||||
$primaryId = (int) ($stu->parent_id ?? 0);
|
||||
$schoolYear = (string) ($stu->school_year ?? $fallbackSchoolYear ?? '');
|
||||
|
||||
$pb = DB::table('parents')->where('firstparent_id', $primaryId);
|
||||
@@ -49,7 +49,7 @@ class AttendanceParentLookupService
|
||||
}
|
||||
|
||||
$pRow = $pb->orderByDesc('updated_at')->first();
|
||||
if (! $pRow) {
|
||||
if (!$pRow) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ class AttendanceParentLookupService
|
||||
->where('id', $secondId)
|
||||
->first();
|
||||
|
||||
if ($u2 && ! empty($u2->email)) {
|
||||
if ($u2 && !empty($u2->email)) {
|
||||
return [
|
||||
'user_id' => (int) $u2->id,
|
||||
'email' => (string) $u2->email,
|
||||
'parent_name' => trim(($u2->firstname ?? '').' '.($u2->lastname ?? '')),
|
||||
'phone' => (string) ($u2->cellphone ?? ''),
|
||||
'user_id' => (int) $u2->id,
|
||||
'email' => (string) $u2->email,
|
||||
'parent_name' => trim(($u2->firstname ?? '') . ' ' . ($u2->lastname ?? '')),
|
||||
'phone' => (string) ($u2->cellphone ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -73,18 +73,18 @@ class AttendanceParentLookupService
|
||||
$fallbackEmail = (string) ($pRow->secondparent_email ?? '');
|
||||
$fallbackPhone = (string) ($pRow->secondparent_phone ?? '');
|
||||
$fallbackFirst = (string) ($pRow->secondparent_firstname ?? '');
|
||||
$fallbackLast = (string) ($pRow->secondparent_lastname ?? '');
|
||||
$fallbackLast = (string) ($pRow->secondparent_lastname ?? '');
|
||||
|
||||
if ($fallbackEmail || $fallbackPhone || $fallbackFirst || $fallbackLast) {
|
||||
return [
|
||||
'user_id' => $secondId ?: null,
|
||||
'email' => $fallbackEmail,
|
||||
'parent_name' => trim($fallbackFirst.' '.$fallbackLast) ?: null,
|
||||
'phone' => $fallbackPhone,
|
||||
'user_id' => $secondId ?: null,
|
||||
'email' => $fallbackEmail,
|
||||
'parent_name' => trim($fallbackFirst . ' ' . $fallbackLast) ?: null,
|
||||
'phone' => $fallbackPhone,
|
||||
];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('getSecondaryParentForStudent() failed: '.$e->getMessage());
|
||||
Log::error('getSecondaryParentForStudent() failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -96,7 +96,7 @@ class AttendanceParentLookupService
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Missing student_id',
|
||||
'status' => 422,
|
||||
'status' => 422,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -106,15 +106,15 @@ class AttendanceParentLookupService
|
||||
->where('id', $studentId)
|
||||
->first();
|
||||
|
||||
if (! $stu) {
|
||||
if (!$stu) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Student not found',
|
||||
'status' => 404,
|
||||
'status' => 404,
|
||||
];
|
||||
}
|
||||
|
||||
$primaryId = (int) $stu->parent_id;
|
||||
$primaryId = (int) $stu->parent_id;
|
||||
$schoolYear = $stu->school_year ?: $currentSchoolYear;
|
||||
|
||||
$u1 = DB::table('users')
|
||||
@@ -123,39 +123,39 @@ class AttendanceParentLookupService
|
||||
->first();
|
||||
|
||||
$primary = $u1 ? [
|
||||
'id' => (int) $u1->id,
|
||||
'id' => (int) $u1->id,
|
||||
'firstname' => (string) $u1->firstname,
|
||||
'lastname' => (string) $u1->lastname,
|
||||
'email' => (string) $u1->email,
|
||||
'lastname' => (string) $u1->lastname,
|
||||
'email' => (string) $u1->email,
|
||||
'cellphone' => (string) $u1->cellphone,
|
||||
] : null;
|
||||
|
||||
$secondaryRaw = $this->getSecondaryParentForStudent($studentId, $schoolYear);
|
||||
|
||||
$secondary = $secondaryRaw ? [
|
||||
'id' => $secondaryRaw['user_id'] ?? null,
|
||||
'id' => $secondaryRaw['user_id'] ?? null,
|
||||
'firstname' => null,
|
||||
'lastname' => null,
|
||||
'email' => $secondaryRaw['email'] ?? '',
|
||||
'lastname' => null,
|
||||
'email' => $secondaryRaw['email'] ?? '',
|
||||
'cellphone' => $secondaryRaw['phone'] ?? '',
|
||||
'name' => $secondaryRaw['parent_name'] ?? '',
|
||||
'name' => $secondaryRaw['parent_name'] ?? '',
|
||||
] : null;
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'primary' => $primary,
|
||||
'data' => [
|
||||
'primary' => $primary,
|
||||
'secondary' => $secondary,
|
||||
],
|
||||
];
|
||||
} catch (Throwable $e) {
|
||||
Log::error('parentsInfo() failed: '.$e->getMessage());
|
||||
Log::error('parentsInfo() failed: ' . $e->getMessage());
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Server error',
|
||||
'status' => 500,
|
||||
'status' => 500,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user