-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use Laravel Prompts for domain input prompt. * Add version matrix to readme.
- Loading branch information
Showing
5 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Lunarstorm\LaravelDDD\Commands\Concerns; | ||
|
||
use Illuminate\Support\Str; | ||
use Lunarstorm\LaravelDDD\Support\DomainResolver; | ||
|
||
use function Laravel\Prompts\suggest; | ||
|
||
trait CanPromptForDomain | ||
{ | ||
protected function promptForDomainName(): string | ||
{ | ||
$choices = collect(DomainResolver::domainChoices()) | ||
->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters