Skip to content

Commit

Permalink
Updating the make commands to use a custom views path
Browse files Browse the repository at this point in the history
This is related to (component, mail, notification) make commands
  • Loading branch information
arcanedev-maroc committed Aug 29, 2020
1 parent 2bad3ad commit cdf19b0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
13 changes: 13 additions & 0 deletions src/Illuminate/Console/GeneratorCommand.php
Expand Up @@ -366,6 +366,19 @@ protected function isReservedName($name)
return in_array($name, $this->reservedNames);
}

/**
* Get the views directory's path.
*
* @param string $path
* @return string
*/
protected function viewsDirectory($path = '')
{
$views = $this->laravel['config']['view.paths'][0] ?? resource_path('views');

return $views.($path ? DIRECTORY_SEPARATOR.$path : $path);
}

/**
* Get the console command arguments.
*
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Foundation/Console/ComponentMakeCommand.php
Expand Up @@ -53,9 +53,9 @@ public function handle()
*/
protected function writeView()
{
$view = $this->getView();

$path = resource_path('views').'/'.str_replace('.', '/', 'components.'.$view);
$path = $this->viewsDirectory(
str_replace('.', '/', 'components.'.$this->getView())
);

if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0777, true, true);
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Foundation/Console/MailMakeCommand.php
Expand Up @@ -51,7 +51,9 @@ public function handle()
*/
protected function writeMarkdownTemplate()
{
$path = resource_path('views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
$path = $this->viewsDirectory(
str_replace('.', '/', $this->option('markdown')).'.blade.php'
);

if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0755, true);
Expand Down
Expand Up @@ -51,7 +51,9 @@ public function handle()
*/
protected function writeMarkdownTemplate()
{
$path = resource_path('views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
$path = $this->viewsDirectory(
str_replace('.', '/', $this->option('markdown')).'.blade.php'
);

if (! $this->files->isDirectory(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0755, true);
Expand Down

0 comments on commit cdf19b0

Please sign in to comment.