From c27ed95ace17d63f88b5189878bdd482491bbbda Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Tue, 8 Nov 2022 17:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/Remote/Host.php | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/app/Jobs/Remote/Host.php b/app/Jobs/Remote/Host.php index faf2bba..cd1a6d0 100644 --- a/app/Jobs/Remote/Host.php +++ b/app/Jobs/Remote/Host.php @@ -38,9 +38,6 @@ public function handle() { // - // dd($this->host); - - // $host = HostModel::find($this->host); $host = $this->host; $host->load(['module']); @@ -49,43 +46,29 @@ public function handle() switch ($this->type) { case 'patch': $response = $http->patch('hosts/' . $host->id, $host->toArray()); + break; case 'post': $response = $http->post('hosts', $host->toArray()); break; - case 'delete': $response = $http->delete('hosts/' . $host->id); // if successful - if ($response->successful()) { + if ($response->successful() || $response->status() === 404) { $host->delete(); } - if ($response->status() === 404) { - $host->delete(); - } - - return 0; - // if response code is 404 - // if ($response->successful() || $response->failed()) { - // $host->delete(); - // } - - - // if success - // if ($response->successful()) { - // $host->delete(); - // } - break; } - if (!$response->successful()) { - $host->status = 'error'; - } + if ($this->type !== 'delete') { + if (!$response->successful()) { + $host->status = 'error'; + } - $host->save(); + $host->save(); + } } }