app/Console/Commands/ControllerMakeCommand.php
protected function appendRouteFile()
    {
        $name = $this->qualifyClass($this->getNameInput());
        $nameWithoutNamespace = str_replace($this->getDefaultNamespace(trim($this->rootNamespace(), '\\')).'\\', '', $name);

        $file = $this->option('api') ? base_path('routes/api.php') : base_path('routes/web.php');
        $routeName = $this->getRouteName($name);
        $routePath = $this->getRoutePath($name);

        $routeDefinition = 'Route::get(\''.$routePath.'\', \''.$nameWithoutNamespace.'\')->name(\''.$routeName.'\');'.PHP_EOL;

        if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
            $asExploded = explode('/', $routePath);
            if (count($asExploded) > 1) {
                array_pop($asExploded);
                $as = implode('.', $asExploded);
                if ($this->option('api'))
                    $routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \''.$as.'\' ]);'.PHP_EOL;
                else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
            } else {
                if ($this->option('api'))
                    $routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \'api\' ]);'.PHP_EOL;
                else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
            }
        }

        file_put_contents($file, $routeDefinition, FILE_APPEND);

        $this->warn($file.' modified.');
    }
protected function appendRouteFile()
    {
        $name = $this->qualifyClass($this->getNameInput());
        $nameWithoutNamespace = str_replace($this->getDefaultNamespace(trim($this->rootNamespace(), '\\')).'\\', '', $name);

        $file = $this->option('api') ? base_path('routes/api.php') : base_path('routes/web.php');
        $routeName = $this->getRouteName($name);
        $routePath = $this->getRoutePath($name);

        $routeDefinition = 'Route::get(\''.$routePath.'\', \''.$nameWithoutNamespace.'\')->name(\''.$routeName.'\');'.PHP_EOL;

        if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
            $asExploded = explode('/', $routePath);
            if (count($asExploded) > 1) {
                array_pop($asExploded);
                $as = implode('.', $asExploded);
                if ($this->option('api'))
                    $routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \''.$as.'\' ]);'.PHP_EOL;
                else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
            } else {
                if ($this->option('api'))
                    $routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \'api\' ]);'.PHP_EOL;
                else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
            }
        }

        file_put_contents($file, $routeDefinition, FILE_APPEND);

        $this->warn($file.' modified.');
    }
protected function appendRouteFile ( ) { $ name = $ this -> qualifyClass ( $ this -> getNameInput ( ) ) ; $ nameWithoutNamespace = str_replace ( $ this -> getDefaultNamespace ( trim ( $ this -> rootNamespace ( ) , '\\' ) ) . '\\' , '' , $ name ) ; $ file = $ this -> option ( 'api' ) ? base_path ( 'routes/api.php' ) : base_path ( 'routes/web.php' ) ; $ routeName = $ this -> getRouteName ( $ name ) ; $ routePath = $ this -> getRoutePath ( $ name ) ; $ routeDefinition = 'Route::get(\'' . $ routePath . '\', \'' . $ nameWithoutNamespace . '\')->name(\'' . $ routeName . '\');' . PHP_EOL ; if ( $ this -> option ( 'parent' ) || $ this -> option ( 'model' ) || $ this -> option ( 'resource' ) ) { $ asExploded = explode ( '/' , $ routePath ) ; if ( count ( $ asExploded ) > 1 ) { array_pop ( $ asExploded ) ; $ as = implode ( '.' , $ asExploded ) ; if ( $ this -> option ( 'api' ) ) $ routeDefinition = 'Route::apiResource(\'' . $ routePath . '\', \'' . $ nameWithoutNamespace . '\', [ \'as\' => \'' . $ as . '\' ]);' . PHP_EOL ; else $ routeDefinition = 'Route::resource(\'' . $ routePath . '\', \'' . $ nameWithoutNamespace . '\');' . PHP_EOL ; } else { if ( $ this -> option ( 'api' ) ) $ routeDefinition = 'Route::apiResource(\'' . $ routePath . '\', \'' . $ nameWithoutNamespace . '\', [ \'as\' => \'api\' ]);' . PHP_EOL ; else $ routeDefinition = 'Route::resource(\'' . $ routePath . '\', \'' . $ nameWithoutNamespace . '\');' . PHP_EOL ; } } file_put_contents ( $ file , $ routeDefinition , FILE_APPEND ) ; $ this -> warn ( $ file . ' modified.' ) ; }
Append Route Files
@return void
Append Route Files