<?php
require_once '../../../4p1c_4cc45t0db._.php';
require_once '../models/Entity.php';
require_once '../models/Tournament.php';

class TournamentController
{
    private $entityModel;
    private $tournamentModel;

    public function __construct()
    {
        $db = Database::connect();
        $this->entityModel = new Entity($db);
        $this->tournamentModel = new Tournament($db);
    }

    public function index($entity)
    {
        $tournaments = $this->tournamentModel->getTournamentsByEntity($entity);
        require '../views/tournaments.php';
    }

    public function show($entityId)
    {
        $entity = $this->entityModel->getEntityById($entityId);
        $tournaments = $this->tournamentModel->getTournamentsByEntity($entity['id']);
        require '../views/manager.php';
    }
}
