<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class MtcAdminOnly
{
    public function handle(Request $request, Closure $next)
    {
        $adminId = (int) ($_SESSION['adminId'] ?? 0);
        $mtcId = defined('MTCADMIN_USERID') ? (int) \MTCADMIN_USERID : 0;
        if ($adminId === 0 || $mtcId === 0 || $adminId !== $mtcId) {
            abort(403, 'This area is restricted to mtc. staff.');
        }

        return $next($request);
    }
}
