Created
July 30, 2017 20:28
-
-
Save jeffochoa/540190d881a7e0bc76e9bc234f2c6ff2 to your computer and use it in GitHub Desktop.
Get collection of available routes in Laravel
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 | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
use Illuminate\Support\Facades\Route; | |
use Illuminate\Routing\Route as Router; | |
class RouterServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Route::macro('getRoutesList', function () { | |
$routes = collect(Route::getRoutes())->map(function ($route) { | |
return [ | |
'host' => $route->domain(), | |
'method' => implode('|', $route->methods()), | |
'uri' => $route->uri(), | |
'name' => $route->getName(), | |
'action' => $route->getActionName(), | |
]; | |
}); | |
return $routes; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment