/** * Execute the console command. * * @return void */ public function fire() { if (parent::fire() === false) { return; } if ($this->option('migration')) { $table = Str::plural(Str::snake(class_basename($this->argument('name')))); $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]); } if ($this->option('controller')) { $controller = Str::studly(class_basename($this->argument('name'))); $this->call('make:controller', ['name' => "{$controller}Controller", '--resource' => $this->option('resource')]); } }
/** * Build the class with the given name. * * @param string $name * @return string */ protected function buildClass($name) { $stub = parent::buildClass($name); $model = $this->option('model'); return $model ? $this->replaceModel($stub, $model) : $stub; }
/** * Build the class with the given name. * * Remove the base controller import if we are already in base namespace. * * @param string $name * @return string */ protected function buildClass($name) { $namespace = $this->getNamespace($name); return str_replace("use {$namespace}\\Controller;\n", '', parent::buildClass($name)); }