62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Paymenter\Extensions\Others\UptimeLab\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Carbon\Carbon;
|
|
|
|
class UptimeServer extends Model
|
|
{
|
|
protected $table = 'ext_uptime_servers';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'ip_address',
|
|
'server_type',
|
|
'location',
|
|
'is_active',
|
|
'status',
|
|
'uptime_percentage',
|
|
'last_online',
|
|
'last_offline',
|
|
'last_check',
|
|
'response_time',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'last_online' => 'datetime',
|
|
'last_offline' => 'datetime',
|
|
'last_check' => 'datetime',
|
|
'uptime_percentage' => 'decimal:2',
|
|
];
|
|
|
|
public function getFormattedLastOnlineAttribute()
|
|
{
|
|
if (!$this->last_online) {
|
|
return 'Never';
|
|
}
|
|
|
|
return $this->last_online->diffForHumans();
|
|
}
|
|
|
|
public function getFormattedLastOfflineAttribute()
|
|
{
|
|
if (!$this->last_offline) {
|
|
return 'Never';
|
|
}
|
|
|
|
return $this->last_offline->diffForHumans();
|
|
}
|
|
|
|
public function getStatusColorAttribute()
|
|
{
|
|
return $this->status === 'online' ? 'green' : 'red';
|
|
}
|
|
|
|
public function getStatusIconAttribute()
|
|
{
|
|
return $this->status === 'online' ? 'ri-checkbox-circle-line' : 'ri-close-circle-line';
|
|
}
|
|
}
|