Fix Laravel Pint formatting

This commit is contained in:
root
2026-06-08 23:30:22 -04:00
parent 567dc24649
commit c792b8be05
1288 changed files with 10766 additions and 9669 deletions
@@ -42,7 +42,7 @@ class AttendanceQueryService
$sectionCodes = array_keys($bySection);
$labels = [];
if (!empty($sectionCodes)) {
if (! empty($sectionCodes)) {
$rows = $this->classSection
->query()
->select(['class_section_id', 'class_section_name'])
@@ -52,13 +52,13 @@ class AttendanceQueryService
->toArray();
foreach ($rows as $row) {
$code = (int)$row['class_section_id'];
$name = trim((string)($row['class_section_name'] ?? ''));
$labels[$code] = $name !== '' ? $name : 'Section #' . $code;
$code = (int) $row['class_section_id'];
$name = trim((string) ($row['class_section_name'] ?? ''));
$labels[$code] = $name !== '' ? $name : 'Section #'.$code;
}
foreach ($sectionCodes as $code) {
$labels[$code] ??= 'Section #' . $code;
$labels[$code] ??= 'Section #'.$code;
}
}
@@ -67,10 +67,10 @@ class AttendanceQueryService
if ($sectionCode > 0) {
$assigned = $this->teacherClass->assignedForSectionTerm($sectionCode, $semester, $schoolYear);
$teacherIds = array_map(fn($r) => (int)$r['teacher_id'], $assigned);
$teacherIds = array_map(fn ($r) => (int) $r['teacher_id'], $assigned);
$statusMap = [];
if (!empty($teacherIds)) {
if (! empty($teacherIds)) {
$rows = DB::table('staff_attendance as sa')
->select('sa.user_id', 'sa.status', 'sa.reason')
->where('sa.semester', $semester)
@@ -80,7 +80,7 @@ class AttendanceQueryService
->get();
foreach ($rows as $row) {
$statusMap[(int)$row->user_id] = [
$statusMap[(int) $row->user_id] = [
'status' => $row->status,
'reason' => $row->reason,
];
@@ -88,15 +88,15 @@ class AttendanceQueryService
}
foreach ($assigned 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 = in_array($position, ['main', 'ta'], true) ? $position : 'main';
$name = trim(($teacher['firstname'] ?? '') . ' ' . ($teacher['lastname'] ?? ''));
$name = trim(($teacher['firstname'] ?? '').' '.($teacher['lastname'] ?? ''));
$cell = $statusMap[$teacherId] ?? ['status' => null, 'reason' => null];
$grid[] = [
'teacher_id' => $teacherId,
'name' => $name !== '' ? $name : 'User#' . $teacherId,
'name' => $name !== '' ? $name : 'User#'.$teacherId,
'position' => $position,
'status' => $cell['status'],
'reason' => $cell['reason'],
@@ -125,13 +125,13 @@ class AttendanceQueryService
public function teacherAttendanceFormData(?int $userId, int $requestedSectionId = 0): array
{
if (!$userId) {
if (! $userId) {
throw new RuntimeException('User not logged in.');
}
$teacher = $this->user->find($userId);
$teacherName = $teacher
? trim(($teacher->firstname ?? '') . ' ' . ($teacher->lastname ?? ''))
? trim(($teacher->firstname ?? '').' '.($teacher->lastname ?? ''))
: 'Unknown Teacher';
$semester = $this->attendanceService->currentSemester();
@@ -145,8 +145,8 @@ class AttendanceQueryService
$activeSection = null;
foreach ($assignments as $assignment) {
$cid = (int)($assignment['class_section_id'] ?? 0);
$pk = (int)($assignment['class_section_pk'] ?? 0);
$cid = (int) ($assignment['class_section_id'] ?? 0);
$pk = (int) ($assignment['class_section_pk'] ?? 0);
if ($requestedSectionId > 0 && ($requestedSectionId === $cid || $requestedSectionId === $pk)) {
$activeSection = $assignment;
@@ -156,8 +156,8 @@ class AttendanceQueryService
$activeSection ??= $assignments[0];
$classSectionCode = (int)($activeSection['class_section_id'] ?? 0);
$classSectionPk = (int)($activeSection['class_section_pk'] ?? 0);
$classSectionCode = (int) ($activeSection['class_section_id'] ?? 0);
$classSectionPk = (int) ($activeSection['class_section_pk'] ?? 0);
$classSectionId = $classSectionCode > 0 ? $classSectionCode : $classSectionPk;
if ($classSectionId <= 0) {
@@ -183,11 +183,11 @@ class AttendanceQueryService
$lockedByStudent = [];
$attendanceTable = $this->attendanceData->getTable();
$dateInSundaysSql = 'DATE(`' . $attendanceTable . '`.`date`) IN (' .
implode(',', array_fill(0, count($sundayDates), '?')) . ')';
$dateInSundaysSql = 'DATE(`'.$attendanceTable.'`.`date`) IN ('.
implode(',', array_fill(0, count($sundayDates), '?')).')';
foreach ($students as $student) {
$studentId = (int)$student['id'];
$studentId = (int) $student['id'];
$rows = AttendanceData::query()
->select(['date', 'status', 'is_reported', 'reason', 'modified_by'])
@@ -202,7 +202,7 @@ class AttendanceQueryService
})
->whereRaw($dateInSundaysSql, $sundayDates)
->get()
->map(fn($row) => (array)$row)
->map(fn ($row) => (array) $row)
->all();
$rows = $this->attendanceService->normalizeAttendanceEntries($rows);
@@ -226,8 +226,8 @@ class AttendanceQueryService
$recentHistory = [];
foreach ($recentRows as $row) {
$recentHistory[] = [
'date' => substr((string)($row['date'] ?? ''), 0, 10),
'status' => strtolower((string)($row['status'] ?? '')),
'date' => substr((string) ($row['date'] ?? ''), 0, 10),
'status' => strtolower((string) ($row['status'] ?? '')),
];
}
@@ -253,7 +253,7 @@ class AttendanceQueryService
// missed rows (SQL/driver quirks), still show statuses that match the visible columns.
foreach ($recentRows as $row) {
$d = $this->calendarDateKey($row['date'] ?? null);
if ($d === '' || !in_array($d, $sundayDates, true)) {
if ($d === '' || ! in_array($d, $sundayDates, true)) {
continue;
}
$rowStatus = $row['status'] ?? null;
@@ -340,13 +340,13 @@ class AttendanceQueryService
$teacherRows = [];
if (!empty($assigned)) {
$teacherIds = array_map(static fn($r) => (int)$r['teacher_id'], $assigned);
if (! empty($assigned)) {
$teacherIds = array_map(static fn ($r) => (int) $r['teacher_id'], $assigned);
$statusMap = [];
if (!empty($teacherIds)) {
$staffDateInSql = 'DATE(`sa`.`date`) IN (' .
implode(',', array_fill(0, count($sundayDates), '?')) . ')';
if (! empty($teacherIds)) {
$staffDateInSql = 'DATE(`sa`.`date`) IN ('.
implode(',', array_fill(0, count($sundayDates), '?')).')';
$staffQ = DB::table('staff_attendance as sa')
->select('sa.user_id', 'sa.date', 'sa.status', 'sa.reason')
->where('sa.semester', $semester)
@@ -372,7 +372,7 @@ class AttendanceQueryService
if ($dk === '') {
continue;
}
$statusMap[(int)$row->user_id][$dk] = [
$statusMap[(int) $row->user_id][$dk] = [
'status' => $row->status,
'reason' => $row->reason,
];
@@ -380,10 +380,10 @@ class AttendanceQueryService
}
foreach ($assigned 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 = in_array($position, ['main', 'ta'], true) ? $position : 'main';
$name = trim(($teacher['firstname'] ?? '') . ' ' . ($teacher['lastname'] ?? ''));
$name = trim(($teacher['firstname'] ?? '').' '.($teacher['lastname'] ?? ''));
$history = [];
foreach ($sundayDates as $date) {
@@ -400,7 +400,7 @@ class AttendanceQueryService
$teacherRows[] = [
'teacher_id' => $teacherId,
'position' => $position,
'name' => $name !== '' ? $name : 'User#' . $teacherId,
'name' => $name !== '' ? $name : 'User#'.$teacherId,
'sunday_statuses' => $history,
'today' => $history[$currentSunday] ?? null,
'today_reason' => $todayReason,
@@ -410,8 +410,8 @@ class AttendanceQueryService
$noSchoolDays = [];
$calendarTable = $this->calendar->getTable();
$calDateInSql = 'DATE(`' . $calendarTable . '`.`date`) IN (' .
implode(',', array_fill(0, count($sundayDates), '?')) . ')';
$calDateInSql = 'DATE(`'.$calendarTable.'`.`date`) IN ('.
implode(',', array_fill(0, count($sundayDates), '?')).')';
$calendarRows = $this->calendar->query()
->where('no_school', 1)
->whereRaw($calDateInSql, $sundayDates)
@@ -438,9 +438,9 @@ class AttendanceQueryService
'class_section_id' => $classSectionId,
'sunday_dates' => $sundayDates,
'current_sunday' => $currentSunday,
'enable_attendance' => (int)$this->configuration->getConfig('enable_attendance'),
'can_edit' => ((int)$this->configuration->getConfig('enable_attendance') === 1),
'class_id' => (int)$this->classSection->getClassId($classSectionId),
'enable_attendance' => (int) $this->configuration->getConfig('enable_attendance'),
'can_edit' => ((int) $this->configuration->getConfig('enable_attendance') === 1),
'class_id' => (int) $this->classSection->getClassId($classSectionId),
'no_school_days' => $noSchoolDays,
'today' => $currentSunday,
'locked_by_student' => $lockedByStudent,
@@ -463,7 +463,7 @@ class AttendanceQueryService
->where('sc.school_year', $schoolYear)
->groupBy('classSection.id', 'classSection.class_id', 'classSection.class_section_id', 'classSection.class_section_name')
->get()
->map(fn($row) => $row->toArray())
->map(fn ($row) => $row->toArray())
->all();
};
@@ -492,32 +492,32 @@ class AttendanceQueryService
$sectionCounts = $this->studentClass->getStudentCountsBySection($effectiveTermYear);
foreach ($classSections as $classSection) {
$secPk = (int)($classSection['id'] ?? 0);
$secCodeRaw = (string)($classSection['class_section_id'] ?? '');
$secCode = $secCodeRaw !== '' ? $secCodeRaw : (string)$secPk;
$classId = (int)($classSection['class_id'] ?? 0);
$secPk = (int) ($classSection['id'] ?? 0);
$secCodeRaw = (string) ($classSection['class_section_id'] ?? '');
$secCode = $secCodeRaw !== '' ? $secCodeRaw : (string) $secPk;
$classId = (int) ($classSection['class_id'] ?? 0);
$studentsBySection[$secCode] = [];
$datesBySection[$secCode] = [];
$attendanceData[$secCode] = [];
$attendanceRecord[$secCode] = [];
$countForCode = (int)($sectionCounts[$secCode] ?? 0);
$countForPk = (int)($sectionCounts[$secPk] ?? 0);
$countForCode = (int) ($sectionCounts[$secCode] ?? 0);
$countForPk = (int) ($sectionCounts[$secPk] ?? 0);
$sectionHasStudents = ($countForCode + $countForPk) > 0;
$students = $this->studentClass->getClassStudents($secCode, $effectiveTermYear);
if (!$students && $secPk && (string)$secPk !== (string)$secCode) {
if (! $students && $secPk && (string) $secPk !== (string) $secCode) {
$students = $this->studentClass->getClassStudents($secPk, $effectiveTermYear);
}
if (!$sectionHasStudents || !$students) {
if (! $sectionHasStudents || ! $students) {
continue;
}
// Bulk-load student profiles for the whole section in one query
$studentsArray = is_array($students) ? $students : $students->toArray();
$studentIds = array_map(fn($sc) => (int)($sc['student_id'] ?? $sc->student_id ?? 0), $studentsArray);
$studentIds = array_map(fn ($sc) => (int) ($sc['student_id'] ?? $sc->student_id ?? 0), $studentsArray);
$studentProfiles = $this->student
->query()
->select(['id', 'firstname', 'lastname', 'school_id'])
@@ -525,12 +525,13 @@ class AttendanceQueryService
->where('is_active', 1)
->get()
->keyBy('id')
->map(fn($row) => $row->toArray())
->map(fn ($row) => $row->toArray())
->all();
$activeIds = array_keys($studentProfiles);
if (empty($activeIds)) {
unset($studentsBySection[$secCode], $datesBySection[$secCode], $attendanceData[$secCode], $attendanceRecord[$secCode]);
continue;
}
@@ -539,17 +540,17 @@ class AttendanceQueryService
->whereIn('student_id', $activeIds)
->where(function ($q) use ($secCode, $secPk) {
$q->where('class_section_id', $secCode);
if ($secPk && (string)$secPk !== (string)$secCode) {
if ($secPk && (string) $secPk !== (string) $secCode) {
$q->orWhere('class_section_id', $secPk);
}
})
->when($termSemester !== '', fn($q) => $q->where('semester', $termSemester))
->when($effectiveTermYear !== '', fn($q) => $q->where('school_year', $effectiveTermYear))
->when($termSemester !== '', fn ($q) => $q->where('semester', $termSemester))
->when($effectiveTermYear !== '', fn ($q) => $q->where('school_year', $effectiveTermYear))
->orderBy('date')
->get()
->map(fn($row) => $row->toArray())
->map(fn ($row) => $row->toArray())
->groupBy('student_id')
->map(fn($group) => $group->values()->all())
->map(fn ($group) => $group->values()->all())
->all();
// Bulk-load all attendance records (summaries) for the section in one query
@@ -557,36 +558,36 @@ class AttendanceQueryService
->whereIn('student_id', $activeIds)
->where(function ($q) use ($secCode, $secPk) {
$q->where('class_section_id', $secCode);
if ($secPk && (string)$secPk !== (string)$secCode) {
if ($secPk && (string) $secPk !== (string) $secCode) {
$q->orWhere('class_section_id', $secPk);
}
})
->when($termSemester !== '', fn($q) => $q->where('semester', $termSemester))
->when($effectiveTermYear !== '', fn($q) => $q->where('school_year', $effectiveTermYear))
->when($termSemester !== '', fn ($q) => $q->where('semester', $termSemester))
->when($effectiveTermYear !== '', fn ($q) => $q->where('school_year', $effectiveTermYear))
->get()
->keyBy('student_id')
->map(fn($row) => $row->toArray())
->map(fn ($row) => $row->toArray())
->all();
$hasRoster = false;
foreach ($studentIds as $studentId) {
$student = $studentProfiles[$studentId] ?? null;
if (!$student) {
if (! $student) {
continue;
}
$studentsBySection[$secCode][] = $student;
$studentSchoolMap[$studentId] = (string)($student['school_id'] ?? '');
$studentSchoolMap[$studentId] = (string) ($student['school_id'] ?? '');
$hasRoster = true;
$entries = $this->attendanceService->normalizeAttendanceEntries(
array_map(fn($r) => (array)$r, $allEntries[$studentId] ?? [])
array_map(fn ($r) => (array) $r, $allEntries[$studentId] ?? [])
);
$attendanceData[$secCode][$studentId] = $entries;
foreach ($entries as $entry) {
$d = (string)($entry['date'] ?? '');
$d = (string) ($entry['date'] ?? '');
if ($d !== '') {
$datesBySection[$secCode][$d] = true;
}
@@ -600,8 +601,9 @@ class AttendanceQueryService
];
}
if (!$hasRoster) {
if (! $hasRoster) {
unset($studentsBySection[$secCode], $datesBySection[$secCode], $attendanceData[$secCode], $attendanceRecord[$secCode]);
continue;
}
@@ -610,7 +612,7 @@ class AttendanceQueryService
foreach ($attendanceData as $secId => &$studentEntries) {
foreach ($studentEntries as &$entries) {
usort($entries, static fn($a, $b) => strcmp((string)($a['date'] ?? ''), (string)($b['date'] ?? '')));
usort($entries, static fn ($a, $b) => strcmp((string) ($a['date'] ?? ''), (string) ($b['date'] ?? '')));
}
}
unset($studentEntries, $entries);
@@ -644,9 +646,9 @@ class AttendanceQueryService
->toArray();
foreach ($events as $event) {
$d = substr((string)($event['date'] ?? ''), 0, 10);
$d = substr((string) ($event['date'] ?? ''), 0, 10);
if ($d !== '') {
$noSchoolDays[$d] = trim((string)($event['title'] ?? 'No School')) ?: 'No School';
$noSchoolDays[$d] = trim((string) ($event['title'] ?? 'No School')) ?: 'No School';
}
}
@@ -668,12 +670,12 @@ class AttendanceQueryService
foreach ($studentEntries as $studentId => $entries) {
$statusByDate = [];
foreach ($entries as $entry) {
$d = substr((string)($entry['date'] ?? ''), 0, 10);
$d = substr((string) ($entry['date'] ?? ''), 0, 10);
if ($d === '' || empty($passedDatesSet[$d])) {
continue;
}
$st = strtolower(trim((string)($entry['status'] ?? '')));
if (!in_array($st, ['present', 'absent', 'late'], true)) {
$st = strtolower(trim((string) ($entry['status'] ?? '')));
if (! in_array($st, ['present', 'absent', 'late'], true)) {
continue;
}
$statusByDate[$d] = $st;
@@ -695,9 +697,9 @@ class AttendanceQueryService
$sum = $p + $l + $a;
$record = $attendanceRecord[$secCode][$studentId] ?? [];
$storedSum = (int)($record['total_presence'] ?? 0)
+ (int)($record['total_late'] ?? 0)
+ (int)($record['total_absence'] ?? 0);
$storedSum = (int) ($record['total_presence'] ?? 0)
+ (int) ($record['total_late'] ?? 0)
+ (int) ($record['total_absence'] ?? 0);
if ($storedSum !== $totalPassedDays && $storedSum !== $sum) {
DB::table('attendance_record')
@@ -733,7 +735,7 @@ class AttendanceQueryService
if (auth()->id()) {
$u = $this->user->query()->select('firstname', 'lastname')->find(auth()->id());
if ($u) {
$adminName = trim(($u->firstname ?? '') . ' ' . ($u->lastname ?? ''));
$adminName = trim(($u->firstname ?? '').' '.($u->lastname ?? ''));
}
}
@@ -773,8 +775,8 @@ class AttendanceQueryService
return [];
}
$staffDateInSql = 'DATE(`sa`.`date`) IN (' .
implode(',', array_fill(0, count($sundayDates), '?')) . ')';
$staffDateInSql = 'DATE(`sa`.`date`) IN ('.
implode(',', array_fill(0, count($sundayDates), '?')).')';
$run = static function (
bool $requireTcSemester,
@@ -830,8 +832,8 @@ class AttendanceQueryService
return [];
}
$staffDateInSql = 'DATE(`sa`.`date`) IN (' .
implode(',', array_fill(0, count($sundayDates), '?')) . ')';
$staffDateInSql = 'DATE(`sa`.`date`) IN ('.
implode(',', array_fill(0, count($sundayDates), '?')).')';
$ids = [];
@@ -905,7 +907,7 @@ class AttendanceQueryService
*/
private function calendarDateKey(mixed $value): string
{
$s = trim((string)($value ?? ''));
$s = trim((string) ($value ?? ''));
if ($s === '') {
return '';
}