<?php
namespace App\Models;
use CodeIgniter\Model;

class NotificationModel extends Model
{
    protected $table         = 'notifications';
    protected $primaryKey    = 'id';
    protected $useTimestamps  = false;
    protected $updatedField  = '';
    protected $allowedFields = ['company_id','user_id','activity_log_id','type','read_at',
        'created_at', 'updated_at', 'deleted_at'];

    public function unreadCount(int $userId, int $companyId): int
    {
        return $this->where('user_id', $userId)->where('company_id', $companyId)->whereNull('read_at')->countAllResults();
    }
}
