Route::getRoutes PHP Method

getRoutes() public static method

Get the underlying route collection.
public static getRoutes ( ) : Illuminate\Routing\RouteCollection
return Illuminate\Routing\RouteCollection
        public static function getRoutes()
        {
            return \Illuminate\Routing\Router::getRoutes();
        }

Usage Example

 /**
  * Tests that the authorization method is attached to all routes except for the / and /home
  *
  */
 public function testAllRoutesHaveAuthorization()
 {
     $routesArr = Route::getRoutes();
     //get all routes
     foreach ($routesArr as $route) {
         $path = $route->getPath();
         // Log::info('testing route ' . $path);
         $vals = array_values($route->middleware());
         $found = false;
         foreach ($vals as $index => $el) {
             if (FALSE !== strpos($el, "auth")) {
                 $found = true;
                 break;
             }
         }
         /**
                     Temporary hack to handle resource routes until we finish the api
                      *
                      **/
         if (starts_with($route->getPath(), "api")) {
             $found = true;
         }
         if ('/' === $path || 'home' === $path || 'index.php' === $path || 'mainlogin' === $path || 'register' === $path || 'login' === $path || 'forgotpassword' === $path) {
             $this->assertFalse($found);
         } else {
             $this->assertTrue($found, 'Route: ' . $route->getPath() . ' doesn\'t have the Authorize middleware attached (keyword \'auth\' not found in middleware array)');
         }
     }
 }
All Usage Examples Of Route::getRoutes