Skip to content

Commit cdf19b0

Browse files
Updating the make commands to use a custom views path
This is related to (component, mail, notification) make commands
1 parent 2bad3ad commit cdf19b0

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/Illuminate/Console/GeneratorCommand.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,19 @@ protected function isReservedName($name)
366366
return in_array($name, $this->reservedNames);
367367
}
368368

369+
/**
370+
* Get the views directory's path.
371+
*
372+
* @param string $path
373+
* @return string
374+
*/
375+
protected function viewsDirectory($path = '')
376+
{
377+
$views = $this->laravel['config']['view.paths'][0] ?? resource_path('views');
378+
379+
return $views.($path ? DIRECTORY_SEPARATOR.$path : $path);
380+
}
381+
369382
/**
370383
* Get the console command arguments.
371384
*

src/Illuminate/Foundation/Console/ComponentMakeCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public function handle()
5353
*/
5454
protected function writeView()
5555
{
56-
$view = $this->getView();
57-
58-
$path = resource_path('views').'/'.str_replace('.', '/', 'components.'.$view);
56+
$path = $this->viewsDirectory(
57+
str_replace('.', '/', 'components.'.$this->getView())
58+
);
5959

6060
if (! $this->files->isDirectory(dirname($path))) {
6161
$this->files->makeDirectory(dirname($path), 0777, true, true);

src/Illuminate/Foundation/Console/MailMakeCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function handle()
5151
*/
5252
protected function writeMarkdownTemplate()
5353
{
54-
$path = resource_path('views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
54+
$path = $this->viewsDirectory(
55+
str_replace('.', '/', $this->option('markdown')).'.blade.php'
56+
);
5557

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

src/Illuminate/Foundation/Console/NotificationMakeCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function handle()
5151
*/
5252
protected function writeMarkdownTemplate()
5353
{
54-
$path = resource_path('views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
54+
$path = $this->viewsDirectory(
55+
str_replace('.', '/', $this->option('markdown')).'.blade.php'
56+
);
5557

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

0 commit comments

Comments
 (0)