使用 状态判断

This commit is contained in:
iVampireSP.com 2023-02-13 15:26:43 +08:00
parent ac6112ac20
commit adc461a580
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 3 additions and 3 deletions

View File

@ -51,7 +51,7 @@ public function destroy(HostRequest $request, Host $host): JsonResponse
{
unset($request);
if ($host->status == 'pending') {
if ($host->isPending()) {
// 如果上次更新时间大于 5min
if ($host->updated_at->diffInMinutes(now()) > 5) {
$host->delete();

View File

@ -49,13 +49,13 @@ public function handle(): void
$host = $this->host;
// 忽略 unavailable 状态的 host
if ($this->pass_unavailable && $host->status === 'unavailable') {
if ($this->pass_unavailable && $host->isUnavailable()) {
return;
}
$host->load(['module']);
if ($host->module->status !== 'up') {
if (!$host->module->isUp()) {
Log::warning('模块不可用,跳过主机更新。', [
'host' => $host->name,
'module' => $host->module->name,