diff --git a/src/Illuminate/Foundation/Console/ResourceMakeCommand.php b/src/Illuminate/Foundation/Console/ResourceMakeCommand.php index 1fd28d26e3a1..abaf6f04a35f 100644 --- a/src/Illuminate/Foundation/Console/ResourceMakeCommand.php +++ b/src/Illuminate/Foundation/Console/ResourceMakeCommand.php @@ -51,8 +51,8 @@ public function handle() protected function getStub() { return $this->collection() - ? __DIR__.'/stubs/resource-collection.stub' - : __DIR__.'/stubs/resource.stub'; + ? $this->resolveStubPath('/stubs/resource-collection.stub') + : $this->resolveStubPath('/stubs/resource.stub'); } /** @@ -66,6 +66,19 @@ protected function collection() Str::endsWith($this->argument('name'), 'Collection'); } + /** + * 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; + } + /** * Get the default namespace for the class. * diff --git a/src/Illuminate/Foundation/Console/StubPublishCommand.php b/src/Illuminate/Foundation/Console/StubPublishCommand.php index 8eab4b812d4f..55e86a958423 100644 --- a/src/Illuminate/Foundation/Console/StubPublishCommand.php +++ b/src/Illuminate/Foundation/Console/StubPublishCommand.php @@ -38,6 +38,8 @@ public function handle() __DIR__.'/stubs/model.pivot.stub' => $stubsPath.'/model.pivot.stub', __DIR__.'/stubs/model.stub' => $stubsPath.'/model.stub', __DIR__.'/stubs/request.stub' => $stubsPath.'/request.stub', + __DIR__.'/stubs/resource.stub' => $stubsPath.'/resource.stub', + __DIR__.'/stubs/resource-collection.stub' => $stubsPath.'/resource-collection.stub', __DIR__.'/stubs/test.stub' => $stubsPath.'/test.stub', __DIR__.'/stubs/test.unit.stub' => $stubsPath.'/test.unit.stub', realpath(__DIR__.'/../../Database/Console/Factories/stubs/factory.stub') => $stubsPath.'/factory.stub', diff --git a/src/Illuminate/Foundation/Console/stubs/resource-collection.stub b/src/Illuminate/Foundation/Console/stubs/resource-collection.stub index 037432ca4916..05390d553144 100644 --- a/src/Illuminate/Foundation/Console/stubs/resource-collection.stub +++ b/src/Illuminate/Foundation/Console/stubs/resource-collection.stub @@ -1,10 +1,10 @@