attributes->get('tenant_console'); return view('tenant-console.index', [ 'tenant' => $tenant, 'tenantId' => $tenantId, ]); } /** * Catch-all: 메인 라우트의 컨트롤러를 찾아서 실행 * /tenant-console/{tenantId}/{path} → /{path} 에 매칭되는 메인 라우트 컨트롤러 호출 */ public function dispatch(Request $request, int $tenantId, string $path) { $url = '/' . ltrim($path, '/'); $method = $request->method(); // 메인 라우트에서 매칭되는 라우트 찾기 $fakeRequest = Request::create($url, $method, $request->all()); $fakeRequest->headers->replace($request->headers->all()); try { $route = app(Router::class)->getRoutes()->match($fakeRequest); } catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) { abort(404, "라우트를 찾을 수 없습니다: {$url}"); } catch (\Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException $e) { abort(405, "허용되지 않는 메서드: {$method} {$url}"); } $action = $route->getAction(); if (! isset($action['uses']) || ! is_string($action['uses'])) { abort(404); } // 라우트 파라미터 바인딩 $route->bind($fakeRequest); $params = $route->parameters(); // 컨트롤러 실행 [$controllerClass, $controllerMethod] = explode('@', $action['uses']); $controller = app($controllerClass); return app()->call([$controller, $controllerMethod], $params); } }