<?php
declare(strict_types=1);

namespace App\Controllers;

use App\Core\Controller;
use App\Models\Conference;
use App\Models\HomepageBlockModel;

final class HomeController extends Controller
{
    public function index(): void
    {
        $conferenceModel = new Conference();
        $homeBlockModel = new HomepageBlockModel();

        $conferences = method_exists($conferenceModel, 'activePublic')
            ? $conferenceModel->activePublic()
            : $conferenceModel->all();

        $this->view('home/index', [
            'conferences' => $conferences,
            'homepageHeroes' => $homeBlockModel->byType('hero'),
            'homepageFeatures' => $homeBlockModel->byType('feature'),
            'homepageAnnouncements' => $homeBlockModel->byType('announcement'),
            'homepageHtmlBlocks' => $homeBlockModel->byType('html'),
            'homepageStats' => $homeBlockModel->byType('stat'),
            'latestHomepageBlocks' => $homeBlockModel->latest(6),
        ]);
    }
}
