@@ -77,23 +77,20 @@ public function auto(string $prefix, string $controller, array $options = []): v
77
77
$ except = $ options ['except ' ] ?? [];
78
78
$ patterns = $ options ['patterns ' ] ?? [];
79
79
80
+ $ routeName = trim ($ options ['as ' ] ?? ($ options ['name ' ] ?? trim ($ prefix , '/ ' )), '. ' ) . '. ' ;
81
+ if ($ routeName === '. ' ) {
82
+ $ routeName = '' ;
83
+ }
84
+
80
85
$ this ->router ->group (
81
- array_merge ($ options , [
82
- 'prefix ' => $ prefix ,
83
- 'as ' => isset ($ options ['as ' ])
84
- ? "{$ options ['as ' ]}. "
85
- : (isset ($ options ['name ' ])
86
- ? "{$ options ['name ' ]}. "
87
- : trim ($ prefix , '/ ' ) . '. '
88
- ),
89
- ]),
86
+ array_merge ($ options , ['prefix ' => $ prefix , 'as ' => $ routeName ]),
90
87
function () use ($ controller , $ only , $ except , $ patterns ) {
91
88
[$ class , $ className ] = $ this ->resolveControllerName ($ controller );
92
89
$ classRef = new ReflectionClass ($ class );
93
90
foreach ($ classRef ->getMethods (ReflectionMethod::IS_PUBLIC ) as $ method ) {
94
91
// Check the method should be added into Routes or not.
95
92
if (in_array ($ method ->class , [BaseController::class, "{$ this ->namespace }\\Controller " ])
96
- || $ method ->getDeclaringClass ()->getParentClass ()-> getName () === BaseController::class
93
+ || ( $ method ->getDeclaringClass ()->getParentClass () && $ method -> getDeclaringClass ()-> getParentClass ()-> getName () === BaseController::class)
97
94
|| !$ method ->isPublic ()
98
95
|| str_starts_with ($ method ->name , '__ ' )) {
99
96
continue ;
0 commit comments