@@ -52,11 +52,7 @@ protected function buildRoutes(Controller $controller)
52
52
$ routes = '' ;
53
53
$ methods = array_keys ($ controller ->methods ());
54
54
55
- $ useTuples = config ('blueprint.generate_fqcn_route ' );
56
-
57
- $ className = $ useTuples
58
- ? $ controller ->fullyQualifiedClassName () . '::class '
59
- : '\'' . str_replace ('App\Http\Controllers \\' , '' , $ controller ->fullyQualifiedClassName ()) . '\'' ;
55
+ $ className = $ this ->getClassName ($ controller );
60
56
61
57
$ slug = Str::kebab ($ controller ->prefix ());
62
58
@@ -83,17 +79,38 @@ protected function buildRoutes(Controller $controller)
83
79
84
80
$ methods = array_diff ($ methods , Controller::$ resourceMethods );
85
81
foreach ($ methods as $ method ) {
86
- if ($ useTuples ) {
87
- $ action = "[ {$ className }, ' {$ method }'] " ;
88
- } else {
89
- $ classNameNoQuotes = trim ($ className , '\'' );
90
- $ action = "' {$ classNameNoQuotes }@ {$ method }' " ;
91
- }
92
-
93
- $ routes .= sprintf ("Route::get('%s/%s', %s); " , $ slug , Str::kebab ($ method ), $ action );
82
+ $ routes .= $ this ->buildRouteLine ($ className , $ slug , $ method );
94
83
$ routes .= PHP_EOL ;
95
84
}
96
85
97
86
return trim ($ routes );
98
87
}
88
+
89
+ protected function useTuples ()
90
+ {
91
+ return config ('blueprint.generate_fqcn_route ' );
92
+ }
93
+
94
+ protected function getClassName (Controller $ controller )
95
+ {
96
+ return $ this ->useTuples ()
97
+ ? $ controller ->fullyQualifiedClassName () . '::class '
98
+ : '\'' . str_replace ('App\Http\Controllers \\' , '' , $ controller ->fullyQualifiedClassName ()) . '\'' ;
99
+ }
100
+
101
+ protected function buildRouteLine ($ className , $ slug , $ method )
102
+ {
103
+ if ($ method === '__invoke ' ) {
104
+ return sprintf ("Route::get('%s', %s); " , $ slug , $ className );
105
+ }
106
+
107
+ if ($ this ->useTuples ()) {
108
+ $ action = "[ {$ className }, ' {$ method }'] " ;
109
+ } else {
110
+ $ classNameNoQuotes = trim ($ className , '\'' );
111
+ $ action = "' {$ classNameNoQuotes }@ {$ method }' " ;
112
+ }
113
+
114
+ return sprintf ("Route::get('%s/%s', %s); " , $ slug , Str::kebab ($ method ), $ action );
115
+ }
99
116
}
0 commit comments