<?php

namespace App\Models;

use CodeIgniter\Model;

class NotificationModel extends Model
{
    protected $table = 'notifications';
    protected $primaryKey = 'id';
    protected $allowedFields = ['title', 'message', 'is_dismissed'];
    protected $useTimestamps = true;
    protected $createdField = 'created_at';
    protected $updatedField = 'updated_at';

    public function getActiveNotifications()
    {
        return $this->where('is_dismissed', 0)
                    ->orderBy('created_at', 'DESC')
                    ->findAll();
    }

    public function dismissNotification($id)
    {
        return $this->update($id, ['is_dismissed' => 1]);
    }
} 