From c4a14fc37ec4f0a3846203a3e8190ac9a9a0b2ee Mon Sep 17 00:00:00 2001 From: haroon-mahmood-4276 Date: Wed, 20 Mar 2024 23:42:55 +0500 Subject: [PATCH 1/2] [11.x] Fixed `class` and `class.invokable` stub paths after publish --- .../Foundation/Console/ClassMakeCommand.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ClassMakeCommand.php b/src/Illuminate/Foundation/Console/ClassMakeCommand.php index a5d32b84089d..e6ed8bb11b3d 100644 --- a/src/Illuminate/Foundation/Console/ClassMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ClassMakeCommand.php @@ -37,11 +37,22 @@ class ClassMakeCommand extends GeneratorCommand */ protected function getStub() { - if ($this->option('invokable')) { - return __DIR__.'/stubs/class.invokable.stub'; - } + return $this->option('invokable') + ? $this->resolveStubPath('/stubs/class.invokable.stub') + : $this->resolveStubPath('/stubs/class.stub'); + } - return __DIR__.'/stubs/class.stub'; + /** + * Resolve the fully-qualified path to the stub. + * + * @param string $stub + * @return string + */ + protected function resolveStubPath($stub) + { + return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) + ? $customPath + : __DIR__.$stub; } /** From c3e74756af7b86ca3e383c09062ad4f2e59e514b Mon Sep 17 00:00:00 2001 From: haroon-mahmood-4276 Date: Wed, 20 Mar 2024 23:50:18 +0500 Subject: [PATCH 2/2] [11.x] fixed styling issue --- src/Illuminate/Foundation/Console/ClassMakeCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ClassMakeCommand.php b/src/Illuminate/Foundation/Console/ClassMakeCommand.php index e6ed8bb11b3d..5c091c6098fb 100644 --- a/src/Illuminate/Foundation/Console/ClassMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ClassMakeCommand.php @@ -37,8 +37,8 @@ class ClassMakeCommand extends GeneratorCommand */ protected function getStub() { - return $this->option('invokable') - ? $this->resolveStubPath('/stubs/class.invokable.stub') + return $this->option('invokable') + ? $this->resolveStubPath('/stubs/class.invokable.stub') : $this->resolveStubPath('/stubs/class.stub'); }