Fix Laravel Pint formatting
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace App\Services\Administrator;
|
||||
|
||||
use App\Services\ApplicationUrlService;
|
||||
use App\Services\Staff\StaffTimeOffLinkService;
|
||||
use App\Models\StaffAttendance;
|
||||
use App\Models\User;
|
||||
use App\Services\ApplicationUrlService;
|
||||
use App\Services\SemesterRangeService;
|
||||
use App\Services\Staff\StaffTimeOffLinkService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -20,14 +21,13 @@ class AdministratorAbsenceService
|
||||
protected SemesterRangeService $semesterRangeService,
|
||||
protected StaffTimeOffLinkService $staffTimeOffLinkService,
|
||||
protected ApplicationUrlService $urls,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getAbsenceFormData(int $userId): array
|
||||
{
|
||||
$admin = $this->userModel->find($userId);
|
||||
$displayName = $admin
|
||||
? trim(($admin->firstname ?? '') . ' ' . ($admin->lastname ?? ''))
|
||||
? trim(($admin->firstname ?? '').' '.($admin->lastname ?? ''))
|
||||
: 'Administrator';
|
||||
|
||||
$semester = $this->shared->getSemester();
|
||||
@@ -76,7 +76,7 @@ class AdministratorAbsenceService
|
||||
}
|
||||
|
||||
$reasonBase = $reasonType !== '' ? strtolower($reasonType) : '';
|
||||
$reason = $reasonBase !== '' ? ($reasonBase . ': ' . $reasonText) : $reasonText;
|
||||
$reason = $reasonBase !== '' ? ($reasonBase.': '.$reasonText) : $reasonText;
|
||||
|
||||
$allowedSet = array_fill_keys($this->shared->allowedAbsenceDates(), true);
|
||||
|
||||
@@ -97,13 +97,15 @@ class AdministratorAbsenceService
|
||||
}
|
||||
|
||||
try {
|
||||
$parsed = \Carbon\Carbon::createFromFormat('Y-m-d', $d);
|
||||
$parsed = Carbon::createFromFormat('Y-m-d', $d);
|
||||
if ($parsed->format('Y-m-d') !== $d || empty($allowedSet[$d])) {
|
||||
$invalid[] = $d;
|
||||
|
||||
continue;
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
$invalid[] = $d;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -129,10 +131,10 @@ class AdministratorAbsenceService
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($invalid)) {
|
||||
if (! empty($invalid)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Invalid dates: ' . implode(', ', $invalid),
|
||||
'message' => 'Invalid dates: '.implode(', ', $invalid),
|
||||
'status' => 422,
|
||||
];
|
||||
}
|
||||
@@ -150,7 +152,7 @@ class AdministratorAbsenceService
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => $saved . ' day(s) saved as absent.',
|
||||
'message' => $saved.' day(s) saved as absent.',
|
||||
'saved' => $saved,
|
||||
'dates' => $savedDates,
|
||||
'status' => 200,
|
||||
@@ -169,10 +171,10 @@ class AdministratorAbsenceService
|
||||
): void {
|
||||
try {
|
||||
$user = $this->userModel->find($userId);
|
||||
$fullName = trim(($user->firstname ?? '') . ' ' . ($user->lastname ?? '')) ?: 'Administrator';
|
||||
$fullName = trim(($user->firstname ?? '').' '.($user->lastname ?? '')) ?: 'Administrator';
|
||||
$userEmail = $user->email ?? '';
|
||||
$role = $roleName ?: 'admin';
|
||||
$dateList = !empty($savedDates) ? implode(', ', $savedDates) : implode(', ', $dates);
|
||||
$dateList = ! empty($savedDates) ? implode(', ', $savedDates) : implode(', ', $dates);
|
||||
|
||||
$subject = sprintf(
|
||||
'TimeOff Request: %s (%s) — %s',
|
||||
@@ -184,20 +186,20 @@ class AdministratorAbsenceService
|
||||
$submittedAt = now()->toDateTimeString();
|
||||
|
||||
$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 administrator 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>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 administrator 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>Submitted At</strong></td><td>'.e($submittedAt).'</td></tr>'
|
||||
.'</table>'
|
||||
.'</div>';
|
||||
|
||||
$token = $this->staffTimeOffLinkService->createToken([
|
||||
'uid' => $userId,
|
||||
@@ -213,9 +215,9 @@ class AdministratorAbsenceService
|
||||
|
||||
$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');
|
||||
|
||||
@@ -223,7 +225,7 @@ class AdministratorAbsenceService
|
||||
$message->to($principalEmail)->subject($subject);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Failed to send TimeOff email (admin): ' . $e->getMessage());
|
||||
Log::error('Failed to send TimeOff email (admin): '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user