Skip to content

Commit

Permalink
Add Windows fallback for multisearch prompt (#48565)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher authored Sep 27, 2023
1 parent bef771d commit f402d3f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Illuminate/Console/Concerns/ConfiguresPrompts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Console\Concerns;

use Laravel\Prompts\ConfirmPrompt;
use Laravel\Prompts\MultiSearchPrompt;
use Laravel\Prompts\MultiSelectPrompt;
use Laravel\Prompts\PasswordPrompt;
use Laravel\Prompts\Prompt;
Expand Down Expand Up @@ -87,6 +88,32 @@ function () use ($prompt) {
false,
$prompt->validate
));

MultiSearchPrompt::fallbackUsing(fn (MultiSearchPrompt $prompt) => $this->promptUntilValid(
function () use ($prompt) {
$query = $this->components->ask($prompt->label);

$options = ($prompt->options)($query);

if ($prompt->required === false) {
if (array_is_list($options)) {
return collect($this->components->choice($prompt->label, ['None', ...$options], 'None', multiple: true))
->reject('None')
->values()
->all();
}

return collect($this->components->choice($prompt->label, ['' => 'None', ...$options], '', multiple: true))
->reject('')
->values()
->all();
}

return $this->components->choice($prompt->label, $options, multiple: true);
},
$prompt->required,
$prompt->validate
));
}

/**
Expand Down

0 comments on commit f402d3f

Please sign in to comment.