You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

7 months ago
<?php
namespace App\Controllers;
use App\Models\Notification;
class NotificationController extends AdminController
{
public function __construct()
{
parent::__construct();
}
5 months ago
// Récupérer toutes les notifications selon les règles définies dans le modèle
7 months ago
public function getNotification()
{
$Notification = new Notification();
$notifications = $Notification->getNotifications();
return $this->response->setJSON($notifications);
}
5 months ago
// Marquer une notification comme lue
7 months ago
public function markAsRead(int $id)
{
$Notification = new Notification();
$Notification->markAsRead($id);
return $this->response->setJSON(['status' => 'success']);
}
5 months ago
// Créer une nouvelle notification
7 months ago
public function createNotification(string $message, string $group, ?int $store_id, ?string $link)
{
$Notification = new Notification();
$data = [
'message' => $message,
5 months ago
'is_read' => 0,
7 months ago
'forgroup' => $group,
'store_id' => $store_id,
'link' => $link,
'created_at' => date('Y-m-d H:i:s')
];
$Notification->insertNotification($data);
}
}