mapApiRoutes(); $this->mapShopApiRoutes(); $this->mapWapRoutes(); $this->mapWebRoutes(); $this->mapWebsRoutes(); // $this->mapAdminApiRoutes(); } /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } /** * Define the "api" routes for the application. * * These routes are typically stateless. * * @return void */ protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); Route::middleware('api_verify') ->namespace( $this->namespace."\\Api" ) ->prefix('api') ->group( base_path('routes'.DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR."{$fileName}") ); } } /** * 店铺Api */ protected function mapShopApiRoutes(){ foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'shopApi'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); Route::middleware('shop_verify') ->namespace( $this->namespace."\\ShopApi" ) ->prefix('shopApi') ->group( base_path('routes'.DIRECTORY_SEPARATOR.'shopApi'.DIRECTORY_SEPARATOR."{$fileName}") ); } } /** * Wap端 */ protected function mapWapRoutes() { foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'wap'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); Route::middleware('wap_verify') ->namespace( $this->namespace."\\Wap" ) ->group( base_path('routes'.DIRECTORY_SEPARATOR.'wap'.DIRECTORY_SEPARATOR."{$fileName}") ); } } /** * web 路由规则 * @return void */ protected function mapWebsRoutes(){ foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); $prefix = substr( $fileName,0,strrpos($fileName,'.') ); $nameSpace = ucfirst($prefix); //中间件过滤加载 Route::middleware('web','admin_verify') ->namespace( $this->namespace."\\{$nameSpace}" ) ->group( base_path('routes'.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR."{$fileName}") ); } } /** * 总后台API路由 */ protected function mapAdminApiRoutes(){ foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) { $fileName = basename( $fileName ); $prefix = substr( $fileName,0,strrpos($fileName,'.') ); $nameSpace = ucfirst($prefix); //中间件过滤加载 Route::middleware('adminApi_verify') ->namespace( $this->namespace."\\AdminApi" ) ->group( base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR."{$fileName}") ); } } }