update controllers logic

This commit is contained in:
root
2026-04-23 00:04:35 -04:00
parent 1977a513df
commit ca4ba272fc
353 changed files with 13402 additions and 1301 deletions
@@ -30,8 +30,6 @@ class WhatsappInviteEmailService
$sections = (array) ($payload['sections'] ?? []);
$links = array_values(array_unique(array_filter((array) ($payload['links'] ?? []))));
$parent = $payload['parent'] ?? null;
$schoolYear = $payload['schoolYear'] ?? null;
$semester = $payload['semester'] ?? null;
$items = $this->buildItems($sections, $links);
if (empty($items)) {
@@ -43,29 +41,13 @@ class WhatsappInviteEmailService
? 'Your WhatsApp Group Links (Multiple Classes)'
: 'Your WhatsApp Group Link';
$viewData = [
'parent' => $parent,
'items' => $items,
'sections' => $sections,
'links' => $links,
'schoolYear' => $schoolYear,
'semester' => $semester,
'title' => $subject,
'teacherNames' => $payload['teachers'] ?? [],
];
$bodyHtml = '';
try {
$bodyHtml = view('emails/whatsapp_invite', $viewData, ['saveData' => true]);
} catch (\Throwable $e) {
$lines = ['Assalamu Alaikum,', '', 'Here are your WhatsApp link(s):'];
foreach ($items as $it) {
$lines[] = ' - ' . $it['class_section_name'] . ': ' . $it['invite_link'];
}
$lines[] = '';
$lines[] = 'Jazakumu-llahu khayran.';
$bodyHtml = nl2br(implode("\n", $lines));
$lines = ['Assalamu Alaikum,', '', 'Here are your WhatsApp link(s):'];
foreach ($items as $it) {
$lines[] = ' - '.$it['class_section_name'].': '.$it['invite_link'];
}
$lines[] = '';
$lines[] = 'Jazakumu-llahu khayran.';
$bodyHtml = nl2br(implode("\n", $lines));
$ok = $this->emailService->send($to, $subject, $bodyHtml, 'notifications', $cc);