Skip to content

Commit

Permalink
Exclude method "middleware" from discovered routes
Browse files Browse the repository at this point in the history
  • Loading branch information
LWlook authored Jul 14, 2024
1 parent 6b6f925 commit deec307
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ public function transform(Collection $pendingRoutes): Collection
return $pendingRoutes->each(function (PendingRoute $pendingRoute) {
$pendingRoute->actions = $pendingRoute
->actions
->reject(fn (PendingRouteAction $pendingRouteAction) => in_array(
$pendingRouteAction->method->class,
$this->rejectMethodsInClasses
));
->reject(function (PendingRouteAction $pendingRouteAction) {
if($pendingRouteAction->method->name == "middleware" && is_subclass_of($pendingRouteAction->method->class, "Illuminate\\Routing\\Controllers\\HasMiddleware")){
return true;
}

return in_array(
$pendingRouteAction->method->class,
$this->rejectMethodsInClasses
);
});
});
}
}

0 comments on commit deec307

Please sign in to comment.