<?php

declare(strict_types=1);

namespace App\Models;

use App\Core\Model;

/**
 * Enquiry Model
 *
 * Handles website enquiry submissions.
 */
class Enquiry extends Model
{
    protected string $table = 'enquiries';

    /**
     * Get all new enquiries.
     *
     * @return array<int, array<string, mixed>>
     */
    public function getNew(): array
    {
        return $this->where('status', 'new');
    }

    /**
     * Count new enquiries.
     *
     * @return int
     */
    public function countNew(): int
    {
        $sql = "SELECT COUNT(*) AS total FROM `{$this->table}` WHERE status = 'new'";
        $stmt = $this->db->prepare($sql);
        $stmt->execute();
        return (int) ($stmt->fetch()['total'] ?? 0);
    }
}
