feat: add delete notification button with confirmation in admin notifications

This commit is contained in:
2026-06-14 10:03:59 -04:00
parent 6b2300de07
commit aea0a4d189
5 changed files with 56 additions and 1 deletions

View File

@@ -295,6 +295,26 @@ class AdminController
]);
}
public function deleteNotification(int $id): void
{
$this->requireSuperAdmin();
$notificationModel = new Notification();
$note = $notificationModel->findById($id);
if (!$note) {
$this->view->json(['success' => false, 'message' => 'Notification not found.'], 404);
}
$notificationModel->delete($id);
$this->auditService->log('notification_deleted', 'notification', $id, [
'title' => $note['title'],
]);
$this->view->json(['success' => true, 'message' => 'Notification deleted.']);
}
public function sendNotification(): void
{
$this->requireSuperAdmin();

View File

@@ -143,4 +143,10 @@ class Notification
$result = $this->db->fetch("SELECT COUNT(*) as total FROM users WHERE status = 'active'");
return (int) ($result['total'] ?? 0);
}
public function delete(int $id): void
{
$this->db->delete('notifications', 'id = ?', [$id]);
$this->db->delete('notification_reads', 'notification_id = ?', [$id]);
}
}