diff --git a/src/Illuminate/Foundation/Console/MailMakeCommand.php b/src/Illuminate/Foundation/Console/MailMakeCommand.php index 67be3179c119..740173afe884 100644 --- a/src/Illuminate/Foundation/Console/MailMakeCommand.php +++ b/src/Illuminate/Foundation/Console/MailMakeCommand.php @@ -43,7 +43,7 @@ public function handle() return; } - if ($this->hasOption('markdown')) { + if ($this->option('markdown') !== false) { $this->writeMarkdownTemplate(); } } @@ -55,14 +55,8 @@ public function handle() */ protected function writeMarkdownTemplate() { - $view = $this->option('markdown'); - - if (! $view) { - $view = 'mail.'.Str::kebab(class_basename($this->argument('name'))); - } - $path = $this->viewPath( - str_replace('.', '/', $view).'.blade.php' + str_replace('.', '/', $this->getView()).'.blade.php' ); if (! $this->files->isDirectory(dirname($path))) { @@ -82,13 +76,29 @@ protected function buildClass($name) { $class = parent::buildClass($name); - if ($this->option('markdown')) { - $class = str_replace('DummyView', $this->option('markdown'), $class); + if ($this->option('markdown') !== false) { + $class = str_replace('DummyView', $this->getView(), $class); } return $class; } + /** + * Get the view name. + * + * @return string + */ + protected function getView() + { + $view = $this->option('markdown'); + + if (! $view) { + $view = 'mail.'.Str::kebab(class_basename($this->argument('name'))); + } + + return $view; + } + /** * Get the stub file for the generator. * @@ -97,7 +107,7 @@ protected function buildClass($name) protected function getStub() { return $this->resolveStubPath( - $this->option('markdown') + $this->option('markdown') !== false ? '/stubs/markdown-mail.stub' : '/stubs/mail.stub'); } @@ -136,7 +146,7 @@ protected function getOptions() return [ ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the mailable already exists'], - ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the mailable'], + ['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the mailable', false], ]; } }