<?php

namespace App\Models;

use App\Core\Model;

class GaleriFotoDetailModel extends Model
{
    protected string $table = 'galeri_foto_detail';

    public function getByGaleriId(int $galeriId): array
    {
        $stmt = $this->db->prepare(
            "SELECT * FROM {$this->table} WHERE galeri_id = :id ORDER BY urutan ASC, id ASC"
        );
        $stmt->execute(['id' => $galeriId]);

        return $stmt->fetchAll();
    }

    public function countByGaleriId(int $galeriId): int
    {
        $stmt = $this->db->prepare("SELECT COUNT(*) AS total FROM {$this->table} WHERE galeri_id = :id");
        $stmt->execute(['id' => $galeriId]);

        return (int) $stmt->fetch()['total'];
    }
}
