feat: add delete notification button with confirmation in admin notifications
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user