Fix Laravel Pint formatting
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user