Skip to content

Commit

Permalink
Filter Route from usage:route command too
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbourdeau committed Oct 29, 2019
1 parent b1e1246 commit f9c3a95
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Console/Commands/UsageRouteCommand.php
Expand Up @@ -17,7 +17,20 @@ class UsageRouteCommand extends RouteListCommand

protected function getRoutes()
{
$routes = $this->splitRoutesByMethods(parent::getRoutes());
$regex = config('route-usage.excluding-regex') + ['name' => false, 'uri' => false];

$routes = $this->splitRoutesByMethods(parent::getRoutes())
->filter(function ($route) use ($regex) {
if (
'OPTIONS' == $route['method'] ||
$regex['name'] && preg_match($regex['name'], $route['name']) ||
$regex['uri'] && preg_match($regex['uri'], $route['uri'])
) {
return false;
}

return true;
});

// TODO: sort by updated_at and group by method+path
$routeUsage = RouteUsage::all()->mapWithKeys(function ($r) {
Expand Down

0 comments on commit f9c3a95

Please sign in to comment.