<?php

declare(strict_types=1);

namespace App\Http\Middleware;

use Closure;
use Stancl\Tenancy\Middleware\InitializeTenancyByPath;

class InitializeTenancyBySiteInRequest extends InitializeTenancyByPath
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
    #[\Override]
    public function handle($request, Closure $next)
    {
        self::$onFail = fn($e) => response('Not Found', 404);
        return parent::handle($request, $next);
    }
}
