diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e238028..afe477a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -14,15 +14,15 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] php: [8.3, 8.2, 8.1] - laravel: [11.*, 10.*] + laravel: [11.*, 10.25.*] stability: [prefer-lowest, prefer-stable] include: - laravel: 11.* testbench: 9.* carbon: ^3.0 - - laravel: 10.* + - laravel: 10.25.* testbench: 8.* - carbon: ^2.63 + carbon: 2.* exclude: - laravel: 11.* php: 8.1 diff --git a/README.md b/README.md index 98a820c..6310442 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,14 @@ Laravel-DDD is a toolkit to support domain driven design (DDD) patterns in Laravel applications. One of the pain points when adopting DDD is the inability to use Laravel's native `make:model` artisan command to properly generate domain models, since domain models are not intended to be stored in the `App/Models/*` namespace. This package aims to fill the gaps by providing an equivalent command, `ddd:model`, plus many more. +## Version Compatibility + Laravel | LaravelDDD +:-----------|:----------- + 9.x | 0.x + <10.25 | 0.x + 10.25+ | 1.x + 11.x | 1.x + ## Installation You can install the package via composer: diff --git a/composer.json b/composer.json index ac0fbca..b3fa864 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,9 @@ ], "require": { "php": "^8.1|^8.2|^8.3", - "spatie/laravel-package-tools": "^1.13.0", - "illuminate/contracts": "^10.0|^11.0" + "illuminate/contracts": "^10.17|^11.0", + "laravel/prompts": "^0.1.16", + "spatie/laravel-package-tools": "^1.13.0" }, "require-dev": { "laravel/pint": "^1.0", diff --git a/src/Commands/Concerns/CanPromptForDomain.php b/src/Commands/Concerns/CanPromptForDomain.php new file mode 100644 index 0000000..f4d95e9 --- /dev/null +++ b/src/Commands/Concerns/CanPromptForDomain.php @@ -0,0 +1,35 @@ +mapWithKeys(fn ($name) => [Str::lower($name) => $name]); + + // Prompt for the domain + $domainName = suggest( + label: 'What is the domain?', + options: fn ($value) => collect($choices) + ->filter(fn ($name) => Str::contains($name, $value, ignoreCase: true)) + ->toArray(), + placeholder: 'Start typing to search...', + required: true + ); + + // Normalize the case of the domain name + // if it is an existing domain. + if ($match = $choices->get(Str::lower($domainName))) { + $domainName = $match; + } + + return $domainName; + } +} diff --git a/src/Commands/Concerns/ResolvesDomainFromInput.php b/src/Commands/Concerns/ResolvesDomainFromInput.php index fd32c54..33e1587 100644 --- a/src/Commands/Concerns/ResolvesDomainFromInput.php +++ b/src/Commands/Concerns/ResolvesDomainFromInput.php @@ -10,6 +10,8 @@ trait ResolvesDomainFromInput { + use CanPromptForDomain; + protected ?Domain $domain = null; protected function getOptions() @@ -81,9 +83,7 @@ public function handle() // If the domain is not set, prompt for it if (! $this->domain) { - $this->domain = new Domain( - $this->anticipate('What is the domain?', DomainResolver::domainChoices()) - ); + $this->domain = new Domain($this->promptForDomainName()); } parent::handle();