Skip to content

Commit 18da637

Browse files
committed
Refacto
1 parent 7b94158 commit 18da637

9 files changed

+11
-22
lines changed

src/Console/Commands/ActionCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function handle()
4444
*/
4545
protected function getStub()
4646
{
47-
return $this->resolveStubPath('/stubs/rest/rest-action.stub');
47+
return $this->resolveStubPath('/stubs/rest-action.stub');
4848
}
4949

5050
/**

src/Console/Commands/BaseControllerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function handle()
5656
*/
5757
protected function getStub()
5858
{
59-
return $this->resolveStubPath('/stubs/rest/rest-base-controller.stub');
59+
return $this->resolveStubPath('/stubs/rest-base-controller.stub');
6060
}
6161

6262
/**

src/Console/Commands/BaseResourceCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BaseResourceCommand extends GeneratorCommand implements PromptsForMissingI
4646
*/
4747
protected function getStub()
4848
{
49-
return $this->resolveStubPath('/stubs/rest/rest-base-resource.stub');
49+
return $this->resolveStubPath('/stubs/rest-base-resource.stub');
5050
}
5151

5252
/**

src/Console/Commands/ControllerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function buildClass($name)
9191
*/
9292
protected function getStub()
9393
{
94-
return $this->resolveStubPath('/stubs/rest/rest-controller.stub');
94+
return $this->resolveStubPath('/stubs/rest-controller.stub');
9595
}
9696

9797
/**

src/Console/Commands/DocumentationProviderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DocumentationProviderCommand extends GeneratorCommand implements PromptsFo
3939
*/
4040
protected function getStub()
4141
{
42-
return $this->resolveStubPath('/stubs/rest/rest-documentation-service-provider.stub');
42+
return $this->resolveStubPath('/stubs/rest-documentation-service-provider.stub');
4343
}
4444

4545
/**

src/Console/Commands/InstructionCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function buildClass($name)
6161
*/
6262
protected function getStub()
6363
{
64-
return $this->resolveStubPath('/stubs/rest/rest-instruction.stub');
64+
return $this->resolveStubPath('/stubs/rest-instruction.stub');
6565
}
6666

6767
/**

src/Console/Commands/ResourceCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function buildClass($name)
102102
*/
103103
protected function getStub()
104104
{
105-
return $this->resolveStubPath('/stubs/rest/rest-resource.stub');
105+
return $this->resolveStubPath('/stubs/rest-resource.stub');
106106
}
107107

108108
/**

src/Console/Commands/ResponseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function buildClass($name)
6262
*/
6363
protected function getStub()
6464
{
65-
return $this->resolveStubPath('/stubs/rest/rest-response.stub');
65+
return $this->resolveStubPath('/stubs/rest-response.stub');
6666
}
6767

6868
/**

src/Console/ResolvesStubPath.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,8 @@ trait ResolvesStubPath
1313
*/
1414
protected function resolveStubPath(string $stub): string
1515
{
16-
$customPath = str_replace('rest/', '', $stub);
17-
$relativePath = ltrim($customPath, '/');
18-
19-
$publishedPath = base_path($relativePath);
20-
if (file_exists($publishedPath)) {
21-
return $publishedPath;
22-
}
23-
24-
$baseStubPath = $this->laravel->basePath(trim($stub, '/'));
25-
if (file_exists($baseStubPath)) {
26-
return $baseStubPath;
27-
}
28-
29-
return __DIR__ . '/../Console/stubs/' . basename($customPath);
16+
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
17+
? $customPath
18+
: __DIR__.$stub;
3019
}
3120
}

0 commit comments

Comments
 (0)