Skip to content

Instantly share code, notes, and snippets.

@gbrock
Created May 12, 2023 10:25
Show Gist options
  • Save gbrock/2229a97ab5ea6571d24de804f44f2e7a to your computer and use it in GitHub Desktop.
Save gbrock/2229a97ab5ea6571d24de804f44f2e7a to your computer and use it in GitHub Desktop.
Laravel: Gathers all the currently-used routes and return an array
<?php
/*
Gathers all the currently-used routes and returns an array.
*/
function getFirstLevelRoutes() {
return collect(Route::getRoutes()->getRoutes())->pluck('uri')->map(function ($uri) {
return explode('/', $uri)[0];
})->unique()->filter();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment