<?php

namespace App\Models;

use App\Core\Model;

class GaleriFotoModel extends Model
{
    protected string $table = 'galeri_foto';

    /**
     * Semua album beserta jumlah foto di dalamnya.
     */
    public function getAllWithCount(): array
    {
        $stmt = $this->db->query(
            "SELECT g.*, COUNT(d.id) AS jumlah_foto
             FROM {$this->table} g
             LEFT JOIN galeri_foto_detail d ON d.galeri_id = g.id
             GROUP BY g.id
             ORDER BY g.created_at DESC"
        );

        return $stmt->fetchAll();
    }
}
