Skip to content

Commit 42ba0ef

Browse files
committed
fix route registerar bug
1 parent 8f22cab commit 42ba0ef

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Illuminate/Routing/RouteRegistrar.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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

tests/Routing/RouteRegistrarTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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', [

0 commit comments

Comments
 (0)