Skip to content

Commit aacd2b8

Browse files
pdewittegos
authored andcommitted
Fix 'can' function defined in RouterRegistrar in laravel#54648 but did not work (laravel#57072)
1 parent 90a556e commit aacd2b8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Illuminate/Routing/Route.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,10 @@ public function setAction(array $action)
10071007
$this->domain($this->action['domain']);
10081008
}
10091009

1010+
if (isset($this->action['can'])) {
1011+
$this->can($this->action['can']);
1012+
}
1013+
10101014
return $this;
10111015
}
10121016

tests/Routing/RouteRegistrarTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,15 @@ public function testCanSetMiddlewareOnRegisteredResource()
900900
$this->seeMiddleware(RouteRegistrarMiddlewareStub::class);
901901
}
902902

903+
public function testCanSetMiddlewareCanOnGroups()
904+
{
905+
$this->router->can('test')->group(function ($router) {
906+
$router->get('/');
907+
});
908+
909+
$this->seeMiddleware('can:test');
910+
}
911+
903912
public function testCanSetMiddlewareForSpecifiedMethodsOnRegisteredResource()
904913
{
905914
$this->router->resource('users', RouteRegistrarControllerStub::class)

0 commit comments

Comments
 (0)