tokens->parseToken($token); if (! $payload) { return $this->respondHtml('Sorry, this link is invalid or has expired.', 400); } $email = trim((string) ($payload['email'] ?? '')); $fullName = trim((string) ($payload['name'] ?? '')); if ($email === '') { return $this->respondHtml('Unable to notify the requester because their email was not included.', 400); } $dates = (string) ($payload['dates'] ?? '-'); $role = (string) ($payload['role'] ?? 'staff'); $reason = (string) ($payload['reason'] ?? ''); $reasonType = (string) ($payload['reason_type'] ?? ''); $submittedAt = (string) ($payload['submitted_at'] ?? ''); $origin = (string) ($payload['origin'] ?? 'staff portal'); try { $subject = 'TimeOff Request - Principal Acknowledgment'; $body = '
' .'

Dear '.e($fullName !== '' ? $fullName : 'Staff Member').',

' .'

This is a courtesy confirmation that your time-off request submitted via the ' .e($origin).' has been reviewed by the principal.

' .'' .'' .'' .'' .'' .($submittedAt !== '' ? '' : '') .'
Role'.e($role).'
Dates'.e($dates !== '' ? $dates : '-').'
Reason Type'.e($reasonType !== '' ? $reasonType : '-').'
Reason'.e($reason !== '' ? $reason : '-').'
Submitted At'.e($submittedAt).'
' .'

If you have any follow-up questions, please contact the principal\'s office directly.

' .'

Thank you,
Al Rahma School Administration

' .'
'; $this->mail->send($email, $subject, $body, 'notifications'); } catch (\Throwable $e) { logger()->error('Failed to send TimeOff confirmation to requester: '.$e->getMessage()); return $this->respondHtml( 'Something went wrong while sending the confirmation email. Please contact IT for help.', 500 ); } return $this->respondHtml('Confirmation email sent to the requester. You may close this window.'); } private function respondHtml(string $message, int $statusCode = 200): Response { $html = 'TimeOff' .'' .'

'.e($message).'

' .''; return response($html, $statusCode, [ 'Content-Type' => 'text/html; charset=UTF-8', ]); } }