Fix Pint formatting

This commit is contained in:
root
2026-06-09 01:25:14 -04:00
parent 6be4875c5e
commit 20a0b6c4e5
1485 changed files with 11318 additions and 10273 deletions
+32 -31
View File
@@ -2,12 +2,12 @@
namespace App\Services\Teachers;
use App\Services\ApplicationUrlService;
use App\Services\Staff\StaffTimeOffLinkService;
use App\Models\StaffAttendance;
use App\Models\TeacherClass;
use App\Models\User;
use App\Services\ApplicationUrlService;
use App\Services\SemesterRangeService;
use App\Services\Staff\StaffTimeOffLinkService;
use Carbon\Carbon;
use Illuminate\Support\Facades\Mail;
@@ -18,8 +18,7 @@ class TeacherAbsenceService
private SemesterRangeService $semesterRangeService,
private StaffTimeOffLinkService $staffTimeOffLinkService,
private ApplicationUrlService $urls,
) {
}
) {}
public function formData(int $userId): array
{
@@ -29,7 +28,7 @@ class TeacherAbsenceService
$teacher = User::query()->find($userId);
$displayName = $teacher
? trim(($teacher->firstname ?? '') . ' ' . ($teacher->lastname ?? ''))
? trim(($teacher->firstname ?? '').' '.($teacher->lastname ?? ''))
: 'Teacher';
$existing = StaffAttendance::query()
@@ -76,7 +75,7 @@ class TeacherAbsenceService
}
$reasonBase = $reasonType !== '' ? strtolower($reasonType) : '';
$reason = $reasonBase !== '' ? ($reasonBase . ': ' . $reasonText) : $reasonText;
$reason = $reasonBase !== '' ? ($reasonBase.': '.$reasonText) : $reasonText;
$allowedSet = array_fill_keys($this->allowedAbsenceDates($schoolYear), true);
$roleName = User::getUserRoleName($userId) ?: null;
@@ -97,10 +96,12 @@ class TeacherAbsenceService
$parsed = Carbon::createFromFormat('Y-m-d', $date);
if ($parsed->format('Y-m-d') !== $date || empty($allowedSet[$date])) {
$invalid[] = $date;
continue;
}
} catch (\Throwable) {
$invalid[] = $date;
continue;
}
@@ -126,10 +127,10 @@ class TeacherAbsenceService
}
}
if (!empty($invalid)) {
if (! empty($invalid)) {
return [
'ok' => false,
'message' => 'Invalid dates: ' . implode(', ', $invalid),
'message' => 'Invalid dates: '.implode(', ', $invalid),
'status' => 422,
];
}
@@ -147,7 +148,7 @@ class TeacherAbsenceService
return [
'ok' => true,
'message' => $saved . ' day(s) saved as absent.',
'message' => $saved.' day(s) saved as absent.',
'saved' => $saved,
'dates' => $savedDates,
'status' => 200,
@@ -211,10 +212,10 @@ class TeacherAbsenceService
): void {
try {
$user = User::query()->find($userId);
$fullName = trim(($user->firstname ?? '') . ' ' . ($user->lastname ?? '')) ?: 'Teacher';
$fullName = trim(($user->firstname ?? '').' '.($user->lastname ?? '')) ?: 'Teacher';
$userEmail = $user->email ?? '';
$role = $roleName ?: 'teacher';
$dateList = !empty($savedDates) ? implode(', ', $savedDates) : implode(', ', $dates);
$dateList = ! empty($savedDates) ? implode(', ', $savedDates) : implode(', ', $dates);
$subject = sprintf(
'TimeOff Request: %s (%s) — %s',
@@ -227,21 +228,21 @@ class TeacherAbsenceService
$assignedText = $this->formatAssignedClasses($userId, $schoolYear, $semester);
$body = '<div style="font-family:Arial,Helvetica,sans-serif;font-size:14px;line-height:1.5;">'
. '<h3 style="margin:0 0 8px;">New TimeOff Request</h3>'
. '<p style="margin:0 0 12px;">A staff time-off request was submitted from the teacher portal.</p>'
. '<table cellpadding="6" cellspacing="0" style="border-collapse:collapse;">'
. '<tr><td><strong>Name</strong></td><td>' . e($fullName) . '</td></tr>'
. '<tr><td><strong>Email</strong></td><td>' . e($userEmail) . '</td></tr>'
. '<tr><td><strong>Role</strong></td><td>' . e((string) $role) . '</td></tr>'
. '<tr><td><strong>Semester</strong></td><td>' . e($semester) . '</td></tr>'
. '<tr><td><strong>School Year</strong></td><td>' . e($schoolYear) . '</td></tr>'
. '<tr><td><strong>Reason Type</strong></td><td>' . e($reasonType ?: '-') . '</td></tr>'
. '<tr><td><strong>Reason</strong></td><td>' . e($reasonText) . '</td></tr>'
. '<tr><td><strong>Dates</strong></td><td>' . e($dateList ?: '-') . '</td></tr>'
. '<tr><td><strong>Assigned Class(es)</strong></td><td>' . e($assignedText) . '</td></tr>'
. '<tr><td><strong>Submitted At</strong></td><td>' . e($submittedAt) . '</td></tr>'
. '</table>'
. '</div>';
.'<h3 style="margin:0 0 8px;">New TimeOff Request</h3>'
.'<p style="margin:0 0 12px;">A staff time-off request was submitted from the teacher portal.</p>'
.'<table cellpadding="6" cellspacing="0" style="border-collapse:collapse;">'
.'<tr><td><strong>Name</strong></td><td>'.e($fullName).'</td></tr>'
.'<tr><td><strong>Email</strong></td><td>'.e($userEmail).'</td></tr>'
.'<tr><td><strong>Role</strong></td><td>'.e((string) $role).'</td></tr>'
.'<tr><td><strong>Semester</strong></td><td>'.e($semester).'</td></tr>'
.'<tr><td><strong>School Year</strong></td><td>'.e($schoolYear).'</td></tr>'
.'<tr><td><strong>Reason Type</strong></td><td>'.e($reasonType ?: '-').'</td></tr>'
.'<tr><td><strong>Reason</strong></td><td>'.e($reasonText).'</td></tr>'
.'<tr><td><strong>Dates</strong></td><td>'.e($dateList ?: '-').'</td></tr>'
.'<tr><td><strong>Assigned Class(es)</strong></td><td>'.e($assignedText).'</td></tr>'
.'<tr><td><strong>Submitted At</strong></td><td>'.e($submittedAt).'</td></tr>'
.'</table>'
.'</div>';
$token = $this->staffTimeOffLinkService->createToken([
'uid' => $userId,
@@ -256,9 +257,9 @@ class TeacherAbsenceService
]);
$notifyUrl = $this->urls->timeoffNotifyUrl($token);
$body .= '<p style="margin-top:16px;">Click <a href="' . e($notifyUrl) . '">Send confirmation email to '
. e($fullName)
. '</a> so the staff member is notified automatically. This link expires in 14 days.</p>';
$body .= '<p style="margin-top:16px;">Click <a href="'.e($notifyUrl).'">Send confirmation email to '
.e($fullName)
.'</a> so the staff member is notified automatically. This link expires in 14 days.</p>';
$principalEmail = env('PRINCIPAL_EMAIL', 'principal@alrahmaisgl.org');
@@ -283,10 +284,10 @@ class TeacherAbsenceService
$name = (string) ($assignment['class_section_name'] ?? '');
$role = (string) ($assignment['teacher_role'] ?? '');
if ($name !== '') {
$parts[] = $role !== '' ? ($name . ' (' . $role . ')') : $name;
$parts[] = $role !== '' ? ($name.' ('.$role.')') : $name;
}
}
return !empty($parts) ? implode(', ', $parts) : 'No assigned class';
return ! empty($parts) ? implode(', ', $parts) : 'No assigned class';
}
}
@@ -8,9 +8,7 @@ use App\Models\User;
class TeacherAssignmentService
{
public function __construct(private TeacherConfigService $configService)
{
}
public function __construct(private TeacherConfigService $configService) {}
public function listAssignments(?string $schoolYear = null): array
{
@@ -53,7 +51,7 @@ class TeacherAssignmentService
}
$role = strtolower((string) ($assign['position'] ?? ''));
if (!in_array($role, ['main', 'ta'], true)) {
if (! in_array($role, ['main', 'ta'], true)) {
continue;
}
@@ -73,9 +71,9 @@ class TeacherAssignmentService
continue;
}
$assigned = $assignmentMap[$tid] ?? ['main' => [], 'ta' => []];
$name = trim(($teacher['firstname'] ?? '') . ' ' . ($teacher['lastname'] ?? ''));
$name = trim(($teacher['firstname'] ?? '').' '.($teacher['lastname'] ?? ''));
if ($name === '') {
$name = 'User#' . $tid;
$name = 'User#'.$tid;
}
$teacherData[] = [
@@ -170,7 +168,7 @@ class TeacherAssignmentService
$semester = trim((string) ($input['semester'] ?? $context['semester'] ?? ''));
$schoolYear = trim((string) ($input['school_year'] ?? $context['school_year'] ?? ''));
if ($teacherId <= 0 || $classSectionId <= 0 || !in_array($position, ['main', 'ta'], true) || $schoolYear === '' || $semester === '') {
if ($teacherId <= 0 || $classSectionId <= 0 || ! in_array($position, ['main', 'ta'], true) || $schoolYear === '' || $semester === '') {
return ['ok' => false, 'message' => 'Missing or invalid data for deletion.'];
}
@@ -182,12 +180,12 @@ class TeacherAssignmentService
->where('position', $position)
->first();
if (!$assignment) {
if (! $assignment) {
return ['ok' => false, 'message' => 'Assignment not found.'];
}
$assignment->delete();
return ['ok' => true, 'message' => ucfirst($position) . ' assignment removed successfully.'];
return ['ok' => true, 'message' => ucfirst($position).' assignment removed successfully.'];
}
}
@@ -11,9 +11,7 @@ use Illuminate\Support\Facades\DB;
class TeacherDashboardService
{
public function __construct(private TeacherConfigService $configService)
{
}
public function __construct(private TeacherConfigService $configService) {}
public function classView(int $userId, ?int $requestedClassSectionId = null): array
{
@@ -29,7 +27,7 @@ class TeacherDashboardService
->map(fn ($r) => strtolower((string) $r))
->all();
if (!array_intersect($roles, ['teacher', 'teacher_assistant'])) {
if (! array_intersect($roles, ['teacher', 'teacher_assistant'])) {
throw new \RuntimeException('Access denied.');
}
@@ -50,24 +48,24 @@ class TeacherDashboardService
$activeClassSectionId = null;
if ($requestedClassSectionId && in_array($requestedClassSectionId, $classSectionIds, true)) {
$activeClassSectionId = $requestedClassSectionId;
} elseif (!empty($classSectionIds)) {
} elseif (! empty($classSectionIds)) {
$activeClassSectionId = $classSectionIds[0];
}
$studentsBySection = [];
if (!empty($classSectionIds)) {
if (! empty($classSectionIds)) {
$students = StudentClass::getStudentsByClassSectionIds($classSectionIds);
if (!empty($students)) {
if (! empty($students)) {
$studentIds = array_values(array_unique(array_map(
static fn (array $row) => (int) ($row['student_id'] ?? 0),
$students
)));
$studentIds = array_values(array_filter($studentIds));
$conditionsByStudent = !empty($studentIds)
$conditionsByStudent = ! empty($studentIds)
? StudentMedicalCondition::getMedicalByStudentIds($studentIds)
: [];
$allergiesByStudent = !empty($studentIds)
$allergiesByStudent = ! empty($studentIds)
? StudentAllergy::getAllergiesByStudentIds($studentIds)
: [];
@@ -89,7 +87,7 @@ class TeacherDashboardService
}
$assignedNames = [];
if (!empty($classSectionIds)) {
if (! empty($classSectionIds)) {
$rows = DB::table('teacher_class as tc')
->select('tc.class_section_id', 'tc.position', 'u.firstname', 'u.lastname')
->join('users as u', 'u.id', '=', 'tc.teacher_id')
@@ -103,7 +101,7 @@ class TeacherDashboardService
foreach ($rows as $row) {
$sid = (int) ($row->class_section_id ?? 0);
$pos = strtolower((string) ($row->position ?? ''));
$name = trim(($row->firstname ?? '') . ' ' . ($row->lastname ?? ''));
$name = trim(($row->firstname ?? '').' '.($row->lastname ?? ''));
if ($sid === 0 || $name === '') {
continue;
}