From a1c135f5d07849eae42c9219f62e55f464da298d Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Sun, 15 Dec 2019 17:45:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/event/LoadModuleRoutes.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extend/catcher/event/LoadModuleRoutes.php b/extend/catcher/event/LoadModuleRoutes.php index c636b77..3f502d1 100644 --- a/extend/catcher/event/LoadModuleRoutes.php +++ b/extend/catcher/event/LoadModuleRoutes.php @@ -19,15 +19,18 @@ class LoadModuleRoutes $router = app(Route::class); $domain = config('catch.domain'); + + $routes = $this->getRoutes(); + if ($domain) { - $router->domain($domain, function () use ($router) { - foreach ($this->getRoutes() as $route) { + $router->domain($domain, function () use ($router, $routes) { + foreach ($routes as $route) { include $route; } }); } else { - $router->group(function () use ($router) { - foreach ($this->getRoutes() as $route) { + $router->group(function () use ($router, $routes) { + foreach ($routes as $route) { include $route; } }); @@ -42,7 +45,7 @@ class LoadModuleRoutes protected function getRoutes(): array { $routes = CatchAdmin::getRoutes(); - $routes[] = CatchAdmin::directory() . 'login' . DIRECTORY_SEPARATOR . 'route.php'; + array_push($routes, CatchAdmin::directory() . 'login' . DIRECTORY_SEPARATOR . 'route.php'); return $routes; } }