From d535c62a3683d569bbd627bda860400e7b83132d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 24 Sep 2021 10:16:07 +0100 Subject: [PATCH 1/2] Avoids attempt to question when there is no answers available --- app/Commands/Concerns/InteractsWithIO.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Commands/Concerns/InteractsWithIO.php b/app/Commands/Concerns/InteractsWithIO.php index 893c343..b137552 100644 --- a/app/Commands/Concerns/InteractsWithIO.php +++ b/app/Commands/Concerns/InteractsWithIO.php @@ -46,6 +46,8 @@ public function askForSite($question) $answers = collect($this->forge->sites($this->currentServer()->id)); + abort_if($answers->isEmpty(), 1, 'The server does not have any sites.'); + if (! is_null($name)) { return optional($answers->where('name', $name)->first())->id ?: $name; } @@ -67,6 +69,8 @@ public function askForServer($question) $answers = collect($this->forge->servers()); + abort_if($answers->isEmpty(), 1, 'The account does not have any servers.'); + if (! is_null($name)) { return optional($answers->where('name', $name)->first())->id ?: $name; } @@ -88,6 +92,8 @@ public function askForDaemon($question) $answers = collect($this->forge->daemons($this->currentServer()->id)); + abort_if($answers->isEmpty(), 1, 'The server does not have any daemons.'); + if (! is_null($command)) { return optional($answers->where('command', $command)->first())->id ?: $command; } From fd1b3e29acd9893227635a66e07b4e3bab150776 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 24 Sep 2021 12:55:44 -0500 Subject: [PATCH 2/2] Update InteractsWithIO.php --- app/Commands/Concerns/InteractsWithIO.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Commands/Concerns/InteractsWithIO.php b/app/Commands/Concerns/InteractsWithIO.php index b137552..dfd1c32 100644 --- a/app/Commands/Concerns/InteractsWithIO.php +++ b/app/Commands/Concerns/InteractsWithIO.php @@ -46,7 +46,7 @@ public function askForSite($question) $answers = collect($this->forge->sites($this->currentServer()->id)); - abort_if($answers->isEmpty(), 1, 'The server does not have any sites.'); + abort_if($answers->isEmpty(), 1, 'This server does not have any sites.'); if (! is_null($name)) { return optional($answers->where('name', $name)->first())->id ?: $name; @@ -69,7 +69,7 @@ public function askForServer($question) $answers = collect($this->forge->servers()); - abort_if($answers->isEmpty(), 1, 'The account does not have any servers.'); + abort_if($answers->isEmpty(), 1, 'This account does not have any servers.'); if (! is_null($name)) { return optional($answers->where('name', $name)->first())->id ?: $name; @@ -92,7 +92,7 @@ public function askForDaemon($question) $answers = collect($this->forge->daemons($this->currentServer()->id)); - abort_if($answers->isEmpty(), 1, 'The server does not have any daemons.'); + abort_if($answers->isEmpty(), 1, 'This server does not have any daemons.'); if (! is_null($command)) { return optional($answers->where('command', $command)->first())->id ?: $command;