Skip to content

Commit

Permalink
now makeDTO uses custom stubs if they exists
Browse files Browse the repository at this point in the history
  • Loading branch information
DavoodGhanbarpour committed Dec 14, 2023
1 parent b8b1e59 commit c4d9188
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Console/Commands/MakeDTOCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,21 @@ protected function getPath($name)

protected function getStub(): string
{
return match (true) {
$this->option('resource') => __DIR__ . '/../stubs/resource_dto.stub',
$this->option('simple') => __DIR__ . '/../stubs/simple_dto.stub',
default => __DIR__ . '/../stubs/dto.stub',
};
return $this->resolveStubPath(match (true) {
$this->option('resource') => 'resource_dto.stub',
$this->option('simple') => 'simple_dto.stub',
default => 'dto.stub',
});
}

/**
* Resolve the fully-qualified path to the stub.
*/
protected function resolveStubPath(string $stub): string
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__ . '/../stubs/' . $stub;
}

protected function getOptions(): array
Expand Down

0 comments on commit c4d9188

Please sign in to comment.