Fedeisas\LaravelJsRoutes\Generators\RoutesJavascriptGenerator::make PHP Метод

make() публичный Метод

Compile routes template and generate
public make ( string $path, string $name, array $options = [] ) : boolean
$path string
$name string
$options array
Результат boolean
    public function make($path, $name, array $options = [])
    {
        $options += ['filter' => null, 'prefix' => null];
        $this->parsedRoutes = $this->getParsedRoutes($options['filter'], $options['prefix']);
        $template = $this->file->get(__DIR__ . '/templates/Router.js');
        $template = str_replace("routes: null,", 'routes: ' . json_encode($this->parsedRoutes) . ',', $template);
        $template = str_replace("'Router'", "'" . $options['object'] . "'", $template);
        if ($this->file->isWritable($path)) {
            $filename = $path . '/' . $name;
            return $this->file->put($filename, $template) !== false;
        }
        return false;
    }

Usage Example

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $path = $this->getPath();
     $options = ['filter' => $this->option('filter'), 'object' => $this->option('object'), 'prefix' => $this->option('prefix')];
     if ($this->generator->make($this->option('path'), $this->argument('name'), $options)) {
         return $this->info("Created {$path}");
     }
     $this->error("Could not create {$path}");
 }