<?php

namespace App\Controllers;

require_once BASE_PATH . '/app/helpers/permissions.php';

use PDO;

use App\Core\Controller;
use App\Core\Database;
use App\Core\TenantContext;

class AdminHomepageContentController extends Controller
{

    public function index()
    {

        $db = Database::getInstance();

        $conferenceId =
            TenantContext::conferenceId();

        $stmt = $db->prepare("
            SELECT *
            FROM conference_homepage_content
            WHERE conference_id = ?
            ORDER BY sort_order ASC, id ASC
        ");

        $stmt->execute([
            $conferenceId
        ]);

        $items =
            $stmt->fetchAll(PDO::FETCH_ASSOC);

        $this->render(
            'admin/homepage_content/index',
            [
                'items' => $items
            ]
        );
    }

}
