| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- $return = [
- /*
- * Automatic registration of routes will only happen if this setting is `true`
- */
- 'enabled' => true,
- /*
- * Controllers in these directories that have routing attributes
- * will automatically be registered.
- *
- * Optionally, you can specify group configuration by using key/values
- */
- 'directories' => [
- app_path('Http/Controllers'),
- // app_path('Module/User/Controllers') => [
- // 'prefix' => 'admin',
- // 'middleware' => 'admin',
- // // only register routes in files that match the patterns
- // 'patterns' => ['*Controller.php'],
- // // do not register routes in files that match the patterns
- // 'not_patterns' => [],
- // ],
- ],
- /*
- * This middleware will be applied to all routes.
- */
- 'middleware' => [
- \Illuminate\Routing\Middleware\SubstituteBindings::class
- ],
- /*
- * When enabled, implicitly scoped bindings will be enabled by default.
- * You can override this behaviour by using the `ScopeBindings` attribute, and passing `false` to it.
- *
- * Possible values:
- * - null: use the default behaviour
- * - true: enable implicitly scoped bindings for all routes
- * - false: disable implicitly scoped bindings for all routes
- */
- 'scope-bindings' => null,
- ];
- $modulePath = app_path('Module');
- $files = scandir($modulePath);
- $Modules = [];
- foreach ($files as $file) {
- if ($file !== '.' && $file !== '..') { // 排除当前目录和上级目录
- if (is_dir($modulePath . '/' . $file)) {
- $Modules[] = $file;
- }
- }
- }
- foreach ($Modules as $key => $module) {
- if (is_dir($modulePath . '/' . $module . '/AdminControllers')) {
- // 后台路由
- $return['directories'][app_path('Module/' . $module . '/AdminControllers')] = [
- 'prefix' => config('admin.route.prefix'),
- 'middleware' => config('admin.route.middleware'),
- // only register routes in files that match the patterns
- 'patterns' => ['*Controller.php'],
- // do not register routes in files that match the patterns
- 'not_patterns' => [],
- ];
- }
- if (is_dir($modulePath . '/' . $module . '/Controllers')) {
- // 前台路由,2025-04-02 没用到
- $return['directories'][app_path('Module/' . $module . '/Controllers')] = [
- 'prefix' => 'api',
- 'middleware' => ['web'],
- // only register routes in files that match the patterns
- 'patterns' => ['*Controller.php'],
- // do not register routes in files that match the patterns
- 'not_patterns' => [],
- ];
- }
- }
- return $return;
|