- 
      
- 
        Save zeetabit/d88c8f1a5eabae267071c12f3bc86653 to your computer and use it in GitHub Desktop. 
    Get collection of available routes in Laravel
  
        
  
    
      This file contains hidden or 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