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.
50 lines
1.3 KiB
50 lines
1.3 KiB
<?php
|
|
namespace app\core\notification;
|
|
|
|
use app\core\utils\Cookie;
|
|
|
|
class Notification {
|
|
|
|
protected $CI;
|
|
const COOKIE_KEY = 'lmateliers_notif';
|
|
|
|
public function __construct() {
|
|
// Get CI Instnce
|
|
$this->CI =& get_instance();
|
|
|
|
// Load Model
|
|
$this->CI->load->model('Notification_model');
|
|
}
|
|
|
|
public function setNotificationCookie($user_id) {
|
|
Cookie::create([
|
|
'name' => 'notif',
|
|
'value' => json_encode(array(
|
|
'user_id'=> $user_id,
|
|
)),
|
|
'expire' => '7200', //2days
|
|
'prefix' => $this->CI->config->item('sess_cookie_name').'_',
|
|
// 'domain' => 'localhost'
|
|
]);
|
|
}
|
|
|
|
public function getNotificationCookie() {
|
|
$cookieData = json_decode(get_cookie(self::COOKIE_KEY));
|
|
return $cookieData;
|
|
}
|
|
|
|
public function deleteNotificationCookie() {
|
|
// Delete registration cookie
|
|
Cookie::delete(self::COOKIE_KEY);
|
|
}
|
|
|
|
public function getNotifications() {
|
|
|
|
return $this->CI->Notification_model->get_notifications();
|
|
}
|
|
|
|
|
|
public function updateNotification(int $id, array $data) {
|
|
return $this->CI->Notification_model->update_notification($id, $data);
|
|
}
|
|
}
|