fix gitlab tests
This commit is contained in:
@@ -31,7 +31,7 @@ class TeacherAttendanceSubmissionService
|
||||
callable $currentSemester,
|
||||
callable $currentSchoolYear
|
||||
): array {
|
||||
$rawSection = trim((string) $data['class_section_id']);
|
||||
$rawSection = trim((string)$data['class_section_id']);
|
||||
|
||||
if ($rawSection === '') {
|
||||
throw new RuntimeException('Missing or invalid class section.');
|
||||
@@ -42,36 +42,36 @@ class TeacherAttendanceSubmissionService
|
||||
->where('class_section_id', $rawSection)
|
||||
->first();
|
||||
|
||||
if (! $sectionRow && ctype_digit($rawSection)) {
|
||||
if (!$sectionRow && ctype_digit($rawSection)) {
|
||||
$sectionRow = DB::table('classSection')
|
||||
->select('id', 'class_id', 'class_section_id')
|
||||
->where('id', (int) $rawSection)
|
||||
->where('id', (int)$rawSection)
|
||||
->first();
|
||||
}
|
||||
|
||||
if (! $sectionRow) {
|
||||
if (!$sectionRow) {
|
||||
throw new RuntimeException('Invalid class section.');
|
||||
}
|
||||
|
||||
$classSectionId = (int) $sectionRow->class_section_id;
|
||||
$classSectionPk = (int) ($sectionRow->id ?? 0);
|
||||
$classSectionId = (int)$sectionRow->class_section_id;
|
||||
$classSectionPk = (int)($sectionRow->id ?? 0);
|
||||
$alsoSectionId = ($classSectionPk > 0 && $classSectionPk !== $classSectionId) ? $classSectionPk : null;
|
||||
$classId = (int) $sectionRow->class_id;
|
||||
$classId = (int)$sectionRow->class_id;
|
||||
$attendanceData = $data['attendance'] ?? [];
|
||||
$teachersData = $data['teachers'] ?? [];
|
||||
|
||||
if (empty($attendanceData) || ! is_array($attendanceData)) {
|
||||
if (empty($attendanceData) || !is_array($attendanceData)) {
|
||||
throw new RuntimeException('No student attendance data provided.');
|
||||
}
|
||||
|
||||
if (empty($teachersData) || ! is_array($teachersData)) {
|
||||
if (empty($teachersData) || !is_array($teachersData)) {
|
||||
throw new RuntimeException('No teacher attendance data provided.');
|
||||
}
|
||||
|
||||
$rawDate = $data['date'] ?? now()->toDateString();
|
||||
$attendDate = Carbon::parse($rawDate)->toDateString();
|
||||
$semester = (string) $currentSemester();
|
||||
$schoolYear = (string) $currentSchoolYear();
|
||||
$semester = (string)$currentSemester();
|
||||
$schoolYear = (string)$currentSchoolYear();
|
||||
|
||||
$dayRow = AttendanceDay::query()
|
||||
->where('class_section_id', $classSectionId)
|
||||
@@ -94,7 +94,7 @@ class TeacherAttendanceSubmissionService
|
||||
'school_year' => $schoolYear,
|
||||
];
|
||||
|
||||
if (! $this->attendancePolicyService->canEditDay($dayPolicyRow, $currentUser)) {
|
||||
if (!$this->attendancePolicyService->canEditDay($dayPolicyRow, $currentUser)) {
|
||||
throw new RuntimeException('Attendance is locked for your role.');
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class TeacherAttendanceSubmissionService
|
||||
|
||||
$existingByStudent = [];
|
||||
foreach ($existingRows as $row) {
|
||||
$existingByStudent[(int) $row->student_id] = $row->toArray();
|
||||
$existingByStudent[(int)$row->student_id] = $row->toArray();
|
||||
}
|
||||
|
||||
$allowedStatuses = ['present', 'absent', 'late'];
|
||||
@@ -129,10 +129,10 @@ class TeacherAttendanceSubmissionService
|
||||
}
|
||||
|
||||
foreach ($assignedTeachers as $teacher) {
|
||||
$teacherId = (int) $teacher['teacher_id'];
|
||||
$status = strtolower((string) ($teachersData[$teacherId]['status'] ?? ''));
|
||||
$teacherId = (int)$teacher['teacher_id'];
|
||||
$status = strtolower((string)($teachersData[$teacherId]['status'] ?? ''));
|
||||
|
||||
if (! in_array($status, $allowedStatuses, true)) {
|
||||
if (!in_array($status, $allowedStatuses, true)) {
|
||||
throw new RuntimeException('Please fill teacher attendance for all assigned teachers.');
|
||||
}
|
||||
}
|
||||
@@ -168,13 +168,13 @@ class TeacherAttendanceSubmissionService
|
||||
);
|
||||
|
||||
foreach ($assignedTeachers as $teacher) {
|
||||
$teacherId = (int) $teacher['teacher_id'];
|
||||
$position = strtolower((string) ($teacher['position'] ?? 'main'));
|
||||
$teacherId = (int)$teacher['teacher_id'];
|
||||
$position = strtolower((string)($teacher['position'] ?? 'main'));
|
||||
$position = $position === 'ta' ? 'ta' : 'main';
|
||||
|
||||
$staffPayload = [
|
||||
'role_name' => 'Teacher',
|
||||
'status' => strtolower((string) ($teachersData[$teacherId]['status'] ?? 'present')),
|
||||
'status' => strtolower((string)($teachersData[$teacherId]['status'] ?? 'present')),
|
||||
'reason' => ($teachersData[$teacherId]['reason'] ?? null) ?: null,
|
||||
'updated_at' => now(),
|
||||
'created_at' => now(),
|
||||
@@ -198,9 +198,9 @@ class TeacherAttendanceSubmissionService
|
||||
}
|
||||
|
||||
foreach ($attendanceData as $row) {
|
||||
$studentId = (int) ($row['student_id'] ?? 0);
|
||||
$status = strtolower(trim((string) ($row['status'] ?? '')));
|
||||
$reason = trim((string) ($row['reason'] ?? ''));
|
||||
$studentId = (int)($row['student_id'] ?? 0);
|
||||
$status = strtolower(trim((string)($row['status'] ?? '')));
|
||||
$reason = trim((string)($row['reason'] ?? ''));
|
||||
$existing = $existingByStudent[$studentId] ?? null;
|
||||
|
||||
if ($isTeacher && $existing) {
|
||||
|
||||
Reference in New Issue
Block a user