From bafbec47ead2435dba18e59923ed150d8eb40b11 Mon Sep 17 00:00:00 2001 From: Haroon Mahmood <70590766+haroon-mahmood-4276@users.noreply.github.com> Date: Tue, 19 Mar 2024 03:24:28 +0500 Subject: [PATCH] [11.x] Fixed enum and enum.backed stub paths after publish (#50629) * [11.x] Fixed enum and enum.backed stub paths after publish * [11.x] linting issue --- .../Foundation/Console/EnumMakeCommand.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/EnumMakeCommand.php b/src/Illuminate/Foundation/Console/EnumMakeCommand.php index d30bc7c86f6e..a7cfb87c9318 100644 --- a/src/Illuminate/Foundation/Console/EnumMakeCommand.php +++ b/src/Illuminate/Foundation/Console/EnumMakeCommand.php @@ -42,10 +42,23 @@ class EnumMakeCommand extends GeneratorCommand protected function getStub() { if ($this->option('string') || $this->option('int')) { - return __DIR__.'/stubs/enum.backed.stub'; + return $this->resolveStubPath('/stubs/enum.backed.stub'); } - return __DIR__.'/stubs/enum.stub'; + return $this->resolveStubPath('/stubs/enum.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; } /**