Illuminate\Routing\Router::getRoutes PHP Method

getRoutes() public method

Get the underlying route collection.
public getRoutes ( ) : Illuminate\Routing\RouteCollection
return Illuminate\Routing\RouteCollection
    public function getRoutes()
    {
        return $this->routes;
    }

Usage Example

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Prepare input
     $namespace = $this->getNamespace();
     $path = $this->getPath();
     // Prepare schema fields
     if (!$this->option('no-migration')) {
         $this->generateSchemaMigration();
     }
     // 2. Generate model
     $this->call('apigen:model', ['name' => $this->translator->translate($this->argument('name'))->toModelName(), '--path' => $path, '--namespace' => $namespace]);
     // 3. Generate repository
     $this->call('apigen:repository', ['name' => $this->translator->translate($this->argument('name'))->toModelName(), '--path' => $path, '--namespace' => $namespace]);
     // 4. Generate controller
     if (!$this->option('no-controller')) {
         $this->generateController();
     }
     // 5. Setup API route
     if (!$this->option('no-route') && !$this->option('no-controller')) {
         $resourceName = $this->translator->translate($this->argument('name'))->toTableName();
         $repositoryName = $this->translator->translate($this->argument('name'))->toRepositoryName();
         $routeBaseName = "api.{$resourceName}";
         if ($this->router->getRoutes()->hasNamedRoute("{$routeBaseName}.index")) {
             $this->error("Assuming routes for {$this->translator->translate($this->argument('name'))->toReadableName()} already exists.");
         } else {
             $this->info("Setting up route for '{$repositoryName}' ...");
             $routeString = "\n\nRoute::resource('{$resourceName}', '{$namespace}\\{$repositoryName}\\{$repositoryName}Controller', [ 'names' => [ " . "\n    'index' => '{$routeBaseName}.index', " . "\n    'create' => '{$routeBaseName}.create', " . "\n    'store' => '{$routeBaseName}.store', " . "\n    'show' => '{$routeBaseName}.show', " . "\n    'edit' => '{$routeBaseName}.edit', " . "\n    'update' => '{$routeBaseName}.update', " . "\n    'destroy' => '{$routeBaseName}.destroy', " . "\n] ]);";
             $this->filesystem->append(app_path() . '/routes.php', $routeString);
         }
     }
     // 6. Setup administration interface if needed
     if (!$this->option('no-admin')) {
         $this->setupAdministrationBackend();
     }
 }
All Usage Examples Of Illuminate\Routing\Router::getRoutes