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.
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
final class CloudResourceReservation extends Model
|
|
{
|
|
protected $connection = 'default';
|
|
protected $table = 'cloud_resource_reservations';
|
|
|
|
protected $casts = [
|
|
'id' => 'int',
|
|
'order_id' => 'int',
|
|
'offer_id' => 'int',
|
|
'resource_pool_id' => 'int',
|
|
'host_id' => 'int',
|
|
'user_id' => 'int',
|
|
'instance_id' => 'int',
|
|
'network_attachment_id' => 'int',
|
|
'public_ip_pool_id' => 'int',
|
|
'public_ip_id' => 'int',
|
|
'cpu_cores' => 'int',
|
|
'memory_mib' => 'int',
|
|
'disk_gib' => 'int',
|
|
'expires_at' => 'int',
|
|
'released_at' => 'int',
|
|
'created_at' => 'int',
|
|
'updated_at' => 'int',
|
|
];
|
|
|
|
/** Every reservation carries a complete immutable network allocation. */
|
|
public function save(array $options = [])
|
|
{
|
|
if (!$this->exists) {
|
|
foreach (['network_attachment_id', 'public_ip_pool_id',
|
|
'public_ip_id'] as $field) {
|
|
if ((int) ($this->{$field} ?? 0) < 1) {
|
|
throw new \LogicException(
|
|
'New reservations require complete network allocation references.'
|
|
);
|
|
}
|
|
}
|
|
}
|
|
return parent::save($options);
|
|
}
|
|
}
|