<?php

namespace App\Controllers;

use App\Core\Controller;
use App\Models\FooterModel;
use App\Models\HalamanModel;
use App\Models\IdentitasModel;
use App\Models\MenuModel;
use App\Models\WidgetModel;

class HalamanController extends Controller
{
    public function show(string $slug): void
    {
        $halamanModel = new HalamanModel();
        $halaman = $halamanModel->getBySlug($slug);

        if (!$halaman) {
            http_response_code(404);
            $this->view('errors/404');
            return;
        }

        $this->view('halaman/show', [
            'halaman'       => $halaman,
            'identitas'     => (new IdentitasModel())->getIdentitas(),
            'menus'         => (new MenuModel())->getMenuUtama(),
            'footerKolom'   => (new FooterModel())->getKolom(),
            'widgetSidebar' => (new WidgetModel())->getByPosisi('sidebar'),
        ]);
    }
}
