<?php

namespace App\Controllers;

use Core\Controller;
use Core\Database;

class MahasiswaTAController extends Controller
{
    public function index()
    {
        $nim = $_SESSION['user']['nim'] ?? null;
        $kompre_eligible = false;

        if ($nim) {
            $pdo = Database::getConnection();
            $stmt = $pdo->prepare("SELECT COUNT(*) FROM tb_kelas WHERE nim = :nim AND smt = 8");
            $stmt->bindParam(':nim', $nim);
            $stmt->execute();
            $kompre_eligible = $stmt->fetchColumn() > 0;
        }

        return $this->view('mahasiswa/ta', [
            'kompre_eligible' => $kompre_eligible
        ]);
    }
}
