Created
May 12, 2023 10:25
-
-
Save gbrock/2229a97ab5ea6571d24de804f44f2e7a to your computer and use it in GitHub Desktop.
Laravel: Gathers all the currently-used routes and return an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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