Misc device column cleanups (#15518)

* Misc device column cleanups
Update last_ping on poll

* Revert inserted change for now
This commit is contained in:
Tony Murray
2023-11-02 01:51:52 -05:00
committed by GitHub
parent 7a72f81ee6
commit 4622742629
2 changed files with 6 additions and 2 deletions

View File

@@ -83,7 +83,9 @@ class Device extends BaseModel
protected $casts = [
'inserted' => 'datetime',
'last_discovered' => 'datetime',
'last_polled' => 'datetime',
'last_ping' => 'datetime',
'status' => 'boolean',
];
@@ -297,9 +299,9 @@ class Device extends BaseModel
return Permissions::canAccessDevice($this->device_id, $user->user_id);
}
public function formatDownUptime($short = false)
public function formatDownUptime($short = false): string
{
$time = ($this->status == 1) ? $this->uptime : time() - strtotime($this->last_polled);
$time = ($this->status == 1) ? $this->uptime : $this->last_polled->diffInSeconds();
return Time::formatInterval($time, $short);
}