Skip to content

Commit

Permalink
[7.x] Fixed component class view reference (#32132)
Browse files Browse the repository at this point in the history
* fixed component class view reference

* Update ComponentMakeCommand.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
innoflash and taylorotwell authored Mar 27, 2020
1 parent a988b65 commit 169cbe8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Illuminate/Foundation/Console/ComponentMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 169cbe8

Please sign in to comment.