resolveStubPath('/stubs/factory.stub'); } /** * Resolve the fully-qualified path to the stub. * * @param string $stub * @return string */ protected function resolveStubPath($stub) { return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) ? $customPath : __DIR__.$stub; } /** * Build the class with the given name. * * @param string $name * @return string */ protected function buildClass($name) { $namespaceModel = $this->option('model') ? $this->qualifyClass($this->option('model')) : trim($this->rootNamespace(), '\\').'\\Model'; $model = class_basename($namespaceModel); $replace = [ 'NamespacedDummyModel' => $namespaceModel, '{{ namespacedModel }}' => $namespaceModel, '{{namespacedModel}}' => $namespaceModel, 'DummyModel' => $model, '{{ model }}' => $model, '{{model}}' => $model, ]; return str_replace( array_keys($replace), array_values($replace), parent::buildClass($name) ); } /** * Get the destination class path. * * @param string $name * @return string */ protected function getPath($name) { $name = str_replace( ['\\', '/'], '', $this->argument('name') ); return $this->laravel->databasePath()."/factories/{$name}.php"; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['model', 'm', InputOption::VALUE_OPTIONAL, 'The name of the model'], ]; } }