emailService->send($to, $subject, $html, 'attendance'); } public function queueAttendanceEvent(array $payload): void { $to = trim((string) data_get($payload, 'parent.email', '')); if ($to === '') { throw new \InvalidArgumentException('No parent email found for attendance notification.'); } $student = (array) ($payload['student'] ?? []); $studentName = trim((string) ($student['firstname'] ?? '') . ' ' . (string) ($student['lastname'] ?? '')); $subjectType = (string) ($payload['subject'] ?? 'Attendance'); $date = substr((string) ($payload['date'] ?? now()->toDateString()), 0, 10); $subject = "Attendance Notice: {$subjectType}"; $body = '
Dear ' . e((string) data_get($payload, 'parent.name', 'Parent/Guardian')) . ',
' . 'This is an attendance notification for your student.
' . 'If you have any questions, please contact the school office.
'; $html = $this->emailComposerService->renderWithEmailLayout($subject, $body); if (!$this->send($to, $subject, $html)) { Log::error('Attendance notification email failed for ' . $to); throw new \RuntimeException('Failed to send attendance notification email.'); } } }