<?php

namespace App\Controllers;

use App\Core\Controller;
use App\Models\AgendaModel;
use App\Models\BeritaModel;
use App\Models\FasilitasModel;
use App\Models\FooterModel;
use App\Models\GaleriFotoModel;
use App\Models\GaleriVideoModel;
use App\Models\IdentitasModel;
use App\Models\MenuModel;
use App\Models\WidgetModel;

class HomeController extends Controller
{
    public function index(): void
    {
        $identitasModel = new IdentitasModel();
        $menuModel      = new MenuModel();
        $beritaModel    = new BeritaModel();
        $agendaModel    = new AgendaModel();
        $widgetModel    = new WidgetModel();
        $footerModel    = new FooterModel();

        $bulanIni = (int) date('n');
        $tahunIni = (int) date('Y');

        $this->view('home/index', [
            'identitas'      => $identitasModel->getIdentitas(),
            'menus'          => $menuModel->getMenuUtama(),
            'berita'         => $beritaModel->getTerbaru(5),
            'agenda'         => $agendaModel->getMendatang(4),
            'tanggalAgenda'  => $agendaModel->getTanggalBulan($bulanIni, $tahunIni),
            'widgetSidebar'  => $widgetModel->getByPosisi('sidebar'),
            'footerKolom'    => $footerModel->getKolom(),
            'bulanIni'       => $bulanIni,
            'tahunIni'       => $tahunIni,
            'albumGaleri'    => array_slice((new GaleriFotoModel())->getAllWithCount(), 0, 3),
            'videoGaleri'    => array_slice((new GaleriVideoModel())->all(), 0, 2),
            'daftarFasilitas' => array_slice((new FasilitasModel())->all(), 0, 6),
        ]);
    }
}
