Skip to content

Instantly share code, notes, and snippets.

View gbrock's full-sized avatar

Greg Brock gbrock

View GitHub Profile
@gbrock
gbrock / helper.php
Created May 12, 2023 10:25
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();