generated from vormkracht10/laravel-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more delimiters in ResendMailCommand prompts. (space and ;)
- Loading branch information
Showing
1 changed file
with
13 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,53 +19,47 @@ public function handle(): int | |
{ | ||
$uuid = $this->argument('uuid'); | ||
|
||
$mail = Mail::where('uuid', $uuid)->first(); | ||
$mail = mail::where('uuid', $uuid)->first(); | ||
|
||
if (is_null($mail)) { | ||
$this->components->error("Mail with UUID: \"{$uuid}\" does not exist"); | ||
$this->components->error("Mail with uuid: \"{$uuid}\" does not exist"); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
info('For the next prompts you can input multiple email addresses by separating them with a comma.'); | ||
|
||
[$to, $cc, $bcc] = $this->promptEmailInputs($mail); | ||
[$to, $cc, $bcc] = $this->promptemailinputs($mail); | ||
|
||
ResendMailJob::dispatch($mail, $to, $cc, $bcc); | ||
|
||
$this->comment('All done'); | ||
info('All done'); | ||
|
||
return self::SUCCESS; | ||
} | ||
|
||
protected function promptEmailInputs(Mail $mail): array | ||
{ | ||
$to = $this->argument('to') ?: explode(',', text( | ||
$to = implode(',', $this->argument('to')) ?: text( | ||
label: 'What email address do you want to send the mail to?', | ||
placeholder: '[email protected]', | ||
)); | ||
); | ||
|
||
$cc = $this->option('cc') ?: explode(',', text( | ||
$cc = implode(',', $this->option('cc')) ?: text( | ||
label: 'What email address should be included in the cc?', | ||
placeholder: '[email protected]', | ||
)); | ||
); | ||
|
||
$bcc = $this->option('bcc') ?: explode(',', text( | ||
$bcc = implode(',', $this->option('bcc')) ?: text( | ||
label: 'What email address should be included in the bcc?', | ||
placeholder: '[email protected]', | ||
)); | ||
); | ||
|
||
$inputs = [ | ||
[&$to, $mail->to], | ||
[&$cc, $mail->cc ?? []], | ||
[&$bcc, $mail->bcc ?? []], | ||
]; | ||
|
||
foreach ($inputs as [&$array, $default]) { | ||
$array = array_filter(array_map(fn ($email) => trim($email), $array)) ?: $default; | ||
foreach ([&$to, &$cc, &$bcc] as &$input) { | ||
$input = array_filter(array_map(fn ($s) => trim($s), explode(' ', str_replace([',', ';'], ' ', $input)))); | ||
} | ||
|
||
return [$to, $cc, $bcc]; | ||
return [$to ?: $mail->to, $cc ?: $mail->cc ?? [], $bcc ?: $mail->bcc ?? []]; | ||
} | ||
|
||
protected function promptForMissingArgumentsUsing() | ||
|