<?php

declare(strict_types=1);

class OcorrenciaHistorico extends Model
{
    public function listarPorOcorrencia(int $ocorrenciaId): array
    {
        $sql = "SELECT h.*, u.nome AS usuario_nome
                FROM ocorrencia_historico h
                LEFT JOIN usuarios u ON u.id = h.usuario_id
                WHERE h.ocorrencia_id = :ocorrencia_id
                ORDER BY h.id DESC";

        $stmt = $this->db->prepare($sql);
        $stmt->execute(['ocorrencia_id' => $ocorrenciaId]);
        return $stmt->fetchAll();
    }
}
