File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,15 @@ protected function compileAction($action)
180180 $ action = ['uses ' => $ action ];
181181 }
182182
183+ if (is_array ($ action ) &&
184+ is_callable ($ action ) &&
185+ ! Arr::isAssoc ($ action )) {
186+ $ action = [
187+ 'uses ' => $ action [0 ].'@ ' .$ action [1 ],
188+ 'controller ' => $ action [0 ].'@ ' .$ action [1 ],
189+ ];
190+ }
191+
183192 return array_merge ($ this ->attributes , $ action );
184193 }
185194
Original file line number Diff line number Diff line change @@ -140,6 +140,15 @@ public function testCanRegisterRouteWithControllerAction()
140140 $ this ->seeMiddleware ('controller-middleware ' );
141141 }
142142
143+ public function testCanRegisterRouteWithControllerActionArray ()
144+ {
145+ $ this ->router ->middleware ('controller-middleware ' )
146+ ->get ('users ' , [RouteRegistrarControllerStub::class, 'index ' ]);
147+
148+ $ this ->seeResponse ('controller ' , Request::create ('users ' , 'GET ' ));
149+ $ this ->seeMiddleware ('controller-middleware ' );
150+ }
151+
143152 public function testCanRegisterRouteWithArrayAndControllerAction ()
144153 {
145154 $ this ->router ->middleware ('controller-middleware ' )->put ('users ' , [
You can’t perform that action at this time.
0 commit comments