Skip to content

Commit

Permalink
Calculate controller middleware before excluding middleware. (#37259)
Browse files Browse the repository at this point in the history
To do so, you can call `withoutMiddleware` in the constructor
  • Loading branch information
allowing authored May 4, 2021
1 parent 154d338 commit d986da0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,13 @@ protected function runRouteWithinStack(Route $route, Request $request)
*/
public function gatherRouteMiddleware(Route $route)
{
$computedMiddleware = $route->gatherMiddleware();

$excluded = collect($route->excludedMiddleware())->map(function ($name) {
return (array) MiddlewareNameResolver::resolve($name, $this->middleware, $this->middlewareGroups);
})->flatten()->values()->all();

$middleware = collect($route->gatherMiddleware())->map(function ($name) {
$middleware = collect($computedMiddleware)->map(function ($name) {
return (array) MiddlewareNameResolver::resolve($name, $this->middleware, $this->middlewareGroups);
})->flatten()->reject(function ($name) use ($excluded) {
if (empty($excluded)) {
Expand Down

0 comments on commit d986da0

Please sign in to comment.