改进 删除逻辑
This commit is contained in:
parent
ec99867379
commit
c27ed95ace
@ -38,9 +38,6 @@ public function handle()
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
// dd($this->host);
|
|
||||||
|
|
||||||
// $host = HostModel::find($this->host);
|
|
||||||
$host = $this->host;
|
$host = $this->host;
|
||||||
$host->load(['module']);
|
$host->load(['module']);
|
||||||
|
|
||||||
@ -49,43 +46,29 @@ public function handle()
|
|||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case 'patch':
|
case 'patch':
|
||||||
$response = $http->patch('hosts/' . $host->id, $host->toArray());
|
$response = $http->patch('hosts/' . $host->id, $host->toArray());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'post':
|
case 'post':
|
||||||
$response = $http->post('hosts', $host->toArray());
|
$response = $http->post('hosts', $host->toArray());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$response = $http->delete('hosts/' . $host->id);
|
$response = $http->delete('hosts/' . $host->id);
|
||||||
|
|
||||||
// if successful
|
// if successful
|
||||||
if ($response->successful()) {
|
if ($response->successful() || $response->status() === 404) {
|
||||||
$host->delete();
|
$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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$response->successful()) {
|
if ($this->type !== 'delete') {
|
||||||
$host->status = 'error';
|
if (!$response->successful()) {
|
||||||
}
|
$host->status = 'error';
|
||||||
|
}
|
||||||
|
|
||||||
$host->save();
|
$host->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user