add test batches
This commit is contained in:
@@ -70,7 +70,7 @@ class StudentAttendanceWriterService
|
||||
|
||||
public function resolveStudentSchoolId(int $studentId, ?string $studentSchoolId = null): string
|
||||
{
|
||||
$studentSchoolId = trim((string) $studentSchoolId);
|
||||
$studentSchoolId = trim((string)$studentSchoolId);
|
||||
|
||||
if ($studentSchoolId !== '') {
|
||||
return $studentSchoolId;
|
||||
@@ -78,25 +78,25 @@ class StudentAttendanceWriterService
|
||||
|
||||
$studentRow = $this->student->query()->select('school_id')->find($studentId);
|
||||
|
||||
if (! $studentRow || empty($studentRow->school_id)) {
|
||||
if (!$studentRow || empty($studentRow->school_id)) {
|
||||
throw new RuntimeException('Student school ID not found.');
|
||||
}
|
||||
|
||||
return (string) $studentRow->school_id;
|
||||
return (string)$studentRow->school_id;
|
||||
}
|
||||
|
||||
public function saveOrUpdateStudentAttendance(array $payload): array
|
||||
{
|
||||
$classSectionId = (int) $payload['class_section_id'];
|
||||
$studentId = (int) $payload['student_id'];
|
||||
$classSectionId = (int)$payload['class_section_id'];
|
||||
$studentId = (int)$payload['student_id'];
|
||||
$studentSchoolId = $this->resolveStudentSchoolId($studentId, $payload['school_id'] ?? null);
|
||||
$status = strtolower((string) $payload['status']);
|
||||
$status = strtolower((string)$payload['status']);
|
||||
$reason = $payload['reason'] ?? null;
|
||||
$reported = $payload['is_reported'] ?? null;
|
||||
$semester = (string) $payload['semester'];
|
||||
$schoolYear = (string) $payload['school_year'];
|
||||
$date = (string) $payload['date'];
|
||||
$classId = (int) $payload['class_id'];
|
||||
$semester = (string)$payload['semester'];
|
||||
$schoolYear = (string)$payload['school_year'];
|
||||
$date = (string)$payload['date'];
|
||||
$classId = (int)$payload['class_id'];
|
||||
$userId = $payload['user_id'] ?? null;
|
||||
|
||||
$existing = AttendanceData::query()
|
||||
@@ -110,7 +110,7 @@ class StudentAttendanceWriterService
|
||||
$oldStatus = $existing->status;
|
||||
|
||||
$this->updateAttendanceData(
|
||||
(int) $existing->id,
|
||||
(int)$existing->id,
|
||||
$status,
|
||||
$reason,
|
||||
$reported,
|
||||
@@ -131,7 +131,7 @@ class StudentAttendanceWriterService
|
||||
|
||||
return [
|
||||
'mode' => 'updated',
|
||||
'attendance_id' => (int) $existing->id,
|
||||
'attendance_id' => (int)$existing->id,
|
||||
'old_status' => $oldStatus,
|
||||
'new_status' => $status,
|
||||
'school_id' => $studentSchoolId,
|
||||
@@ -172,10 +172,10 @@ class StudentAttendanceWriterService
|
||||
|
||||
return [
|
||||
'mode' => 'created',
|
||||
'attendance_id' => (int) ($created->id ?? 0),
|
||||
'attendance_id' => (int)($created->id ?? 0),
|
||||
'old_status' => null,
|
||||
'new_status' => $status,
|
||||
'school_id' => $studentSchoolId,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user