update controllers logic
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user