diff --git a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php index 48c630f505cc..3bcce0d97bf1 100644 --- a/src/Illuminate/Foundation/Console/ComponentMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ComponentMakeCommand.php @@ -53,11 +53,7 @@ public function handle() */ protected function writeView() { - $view = collect(explode('/', $this->argument('name'))) - ->map(function ($part) { - return Str::kebab($part); - }) - ->implode('.'); + $view = $this->getView(); $path = resource_path('views').'/'.str_replace('.', '/', 'components.'.$view); @@ -91,11 +87,25 @@ protected function buildClass($name) return str_replace( 'DummyView', - 'view(\'components.'.Str::kebab(class_basename($name)).'\')', + 'view(\'components.'.$this->getView().'\')', parent::buildClass($name) ); } + /** + * Get the view name relative to the components directory. + * + * @return string view + */ + protected function getView() + { + return collect(explode('/', $this->argument('name'))) + ->map(function ($part) { + return Str::kebab($part); + }) + ->implode('.'); + } + /** * Get the stub file for the generator. *