@@ -238,12 +238,9 @@ public function middleware($middleware = null)
238
238
$ middlewares = (array ) Arr::get ($ this ->action , 'middleware ' , []);
239
239
240
240
if (is_string ($ this ->action ['uses ' ])) {
241
- list ($ class , $ method ) = explode ('@ ' , $ this ->action ['uses ' ]);
242
- $ controller = $ this ->container ->make ($ class );
243
-
244
- $ controllerMiddlewares = (new ControllerDispatcher ($ this ->router , $ this ->container ))
245
- ->getMiddleware ($ controller , $ method );
246
- $ middlewares = array_merge ($ middlewares , $ controllerMiddlewares );
241
+ $ middlewares = array_merge (
242
+ $ middlewares , $ this ->controllerMiddleware ()
243
+ );
247
244
}
248
245
249
246
return $ middlewares ;
@@ -260,6 +257,21 @@ public function middleware($middleware = null)
260
257
return $ this ;
261
258
}
262
259
260
+ /**
261
+ * Get the controller middleware for the route.
262
+ *
263
+ * @return array
264
+ */
265
+ protected function controllerMiddleware ()
266
+ {
267
+ list ($ class , $ method ) = explode ('@ ' , $ this ->action ['uses ' ]);
268
+
269
+ $ controller = $ this ->container ->make ($ class );
270
+
271
+ return (new ControllerDispatcher ($ this ->router , $ this ->container ))
272
+ ->getMiddleware ($ controller , $ method );
273
+ }
274
+
263
275
/**
264
276
* Get the parameters that are listed in the route / controller signature.
265
277
*
0 commit comments