This commit is contained in:
@@ -103,24 +103,14 @@ class WhatsappController extends BaseController
|
||||
$sectionName = $row['class_section_name'] ?? ('Section ' . $sectionId);
|
||||
}
|
||||
|
||||
$existing = $this->linkModel->where([
|
||||
'class_section_id' => $sectionId,
|
||||
'school_year' => $this->schoolYear,
|
||||
])->first();
|
||||
|
||||
$payload = [
|
||||
'class_section_id' => $sectionId,
|
||||
'class_section_name' => $sectionName,
|
||||
'school_year' => $this->schoolYear,
|
||||
'invite_link' => trim($inviteLink),
|
||||
'active' => $active,
|
||||
];
|
||||
|
||||
if ($existing) {
|
||||
$this->linkModel->update($existing['id'], $payload);
|
||||
} else {
|
||||
$this->linkModel->insert($payload);
|
||||
}
|
||||
$this->linkModel->upsertLinkForSection(
|
||||
$sectionId,
|
||||
$sectionName,
|
||||
(string) $this->schoolYear,
|
||||
'',
|
||||
$inviteLink,
|
||||
$active === 1
|
||||
);
|
||||
|
||||
return redirect()->back()->with('success', 'WhatsApp group link saved.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user