Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sorting of route:list by multiple column/factors using a comma #50998

Merged
merged 6 commits into from
Apr 10, 2024
10 changes: 7 additions & 3 deletions src/Illuminate/Foundation/Console/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,13 @@ protected function getRouteInformation(Route $route)
*/
protected function sortRoutes($sort, array $routes)
{
return Arr::sort($routes, function ($route) use ($sort) {
return $route[$sort];
});
if (Str::contains($sort, ',')) {
$sort = explode(',', $sort);
}

return collect($routes)
->sortBy($sort)
->toArray();
}

/**
Expand Down