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.
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
final class CloudPublicIp extends Model
|
|
{
|
|
protected $connection = 'default';
|
|
protected $table = 'cloud_public_ips';
|
|
|
|
protected $casts = [
|
|
'id' => 'int',
|
|
'host_id' => 'int',
|
|
'public_ip_pool_id' => 'int',
|
|
'address_family' => 'int',
|
|
'prefix_length' => 'int',
|
|
'reservation_id' => 'int',
|
|
'reservation_ip_claim_id' => 'int',
|
|
'instance_id' => 'int',
|
|
'created_at' => 'int',
|
|
'updated_at' => 'int',
|
|
];
|
|
|
|
public function reservationClaim()
|
|
{
|
|
return $this->belongsTo(
|
|
CloudResourceReservationIp::class,
|
|
'reservation_ip_claim_id'
|
|
);
|
|
}
|
|
|
|
/** New ledger rows must always belong to one validated public pool. */
|
|
public function save(array $options = [])
|
|
{
|
|
if (!$this->exists) {
|
|
if ((int) ($this->public_ip_pool_id ?? 0) < 1) {
|
|
throw new \LogicException(
|
|
'New public IP rows require a public pool association.'
|
|
);
|
|
}
|
|
}
|
|
return parent::save($options);
|
|
}
|
|
}
|