File tree 3 files changed +18
-11
lines changed
3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -103,13 +103,15 @@ class YOURPACKAGEServiceProvider extends PackageServiceProvider implements Defin
103
103
Add your routes source path:
104
104
``` php
105
105
/**
106
- * returns routes.php file (absolute path )
106
+ * returns routes/web .php|... files (absolute paths )
107
107
*
108
- * @return string
108
+ * @return array| string[]
109
109
*/
110
- public function routesFile ()
110
+ public function routesFiles ()
111
111
{
112
- return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'web.php';
112
+ return [
113
+ __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'web.php'
114
+ ];
113
115
}
114
116
```
115
117
Original file line number Diff line number Diff line change @@ -38,14 +38,19 @@ abstract protected function namespace();
38
38
public function boot ()
39
39
{
40
40
if ( ! $ this ->app ->routesAreCached ()) {
41
+ /** @var \Illuminate\Routing\Router $router */
42
+ $ router = $ this ->app ->make (\Illuminate \Routing \Router::class);
43
+
41
44
if ($ this instanceof DefinesRoutes) {
42
- $ routesFile = $ this ->routesFile ();
43
- require $ routesFile ;
45
+ $ routesFiles = $ this ->routesFiles ();
46
+ foreach ((array )$ routesFiles as $ routesFile ) {
47
+ // $router exists
48
+ if (file_exists ($ routesFile )) {
49
+ require $ routesFile ;
50
+ }
51
+ }
44
52
}
45
53
if ($ this instanceof DefinesRouteRegistrar) {
46
- /** @var \Illuminate\Routing\Router $router */
47
- $ router = $ this ->app ->make (\Illuminate \Routing \Router::class);
48
-
49
54
$ this ->registerRoutesWithRouter ($ router );
50
55
}
51
56
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ interface DefinesRoutes
7
7
/**
8
8
* returns routes.php file (absolute path)
9
9
*
10
- * @return string
10
+ * @return array| string[]
11
11
*/
12
- public function routesFile ();
12
+ public function routesFiles ();
13
13
}
You can’t perform that action at this time.
0 commit comments