<?php

namespace App\Models;

use CodeIgniter\Model;

class ContactMessageModel extends Model
{
    protected $table         = 'contact_messages';
    protected $primaryKey    = 'id';
    protected $returnType = 'array';
    protected $allowedFields = ['name', 'email', 'subject', 'message', 'is_read'];
    protected $useTimestamps = false;
    protected $createdField  = 'created_at';
    protected $updatedField  = null;

    public function getUnreadCount(): int
    {
        return $this->where('is_read', 0)
                    ->countAllResults();
    }
}
