From a743d5960d303499cb2c06a88f9e2ead32c44fb6 Mon Sep 17 00:00:00 2001 From: Haroon Mahmood <70590766+haroon-mahmood-4276@users.noreply.github.com> Date: Thu, 21 Mar 2024 01:06:04 +0500 Subject: [PATCH] [11.x] Fixed `class` and `class.invokable` stub paths after publish (#50676) * [11.x] Fixed `class` and `class.invokable` stub paths after publish * [11.x] fixed styling issue --- .../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..5c091c6098fb 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; } /**