<?php

namespace Modules\ClinicCore\Http\Middleware;

use Closure;

/**
 * Fail-open stand-in for the `module:{Name}` route-middleware alias.
 *
 * The real alias is registered by SaasSwitcher (multi-project hosts) and gates
 * routes by per-business module entitlement. On single-project deployments
 * (e.g. the standalone Shifa One copy) SaasSwitcher is disabled, the alias is
 * never registered, and every route carrying `module:X` throws
 * "Target class [module] does not exist" for authenticated users.
 *
 * ClinicCoreServiceProvider registers THIS class under the `module` alias only
 * when nothing else has claimed it. Single-project = everything entitled, so
 * it simply passes through. When SaasSwitcher boots (dev multi-project host)
 * its own aliasMiddleware() call overwrites this entry with the real
 * entitlement check — boot order does not matter.
 */
class ModuleAliasFallback
{
    public function handle($request, Closure $next, ?string $module = null)
    {
        return $next($request);
    }
}
