You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
final class CloudInstance extends Model
|
|
{
|
|
protected $connection = 'default';
|
|
protected $table = 'cloud_instances';
|
|
protected $casts = [
|
|
'id' => 'int',
|
|
'host_id' => 'int',
|
|
'user_id' => 'int',
|
|
'order_id' => 'int',
|
|
'plan_id' => 'int',
|
|
'offer_id' => 'int',
|
|
'resource_pool_id' => 'int',
|
|
'reservation_id' => 'int',
|
|
'current_period_id' => 'int',
|
|
'expires_at' => 'int',
|
|
'renewal_price' => 'decimal:2',
|
|
'renewal_days' => 'int',
|
|
'renewal_traffic_bytes' => 'int',
|
|
'traffic_quota_bytes' => 'int',
|
|
'created_at' => 'int',
|
|
'updated_at' => 'int',
|
|
];
|
|
protected $hidden = ['credential_cipher'];
|
|
|
|
public function serviceAvailable(?int $now = null): bool
|
|
{
|
|
if ((string) $this->service_status === 'exempt') {
|
|
return true;
|
|
}
|
|
$now ??= time();
|
|
return (string) $this->service_status === 'active'
|
|
&& $this->expires_at !== null
|
|
&& (int) $this->expires_at > $now;
|
|
}
|
|
}
|