84 lines
1.8 KiB
PHP
84 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\LogsActivity;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
class IpPool extends Model
|
|
{
|
|
use HasFactory, SoftDeletes, LogsActivity;
|
|
|
|
protected $fillable = [
|
|
'uuid',
|
|
'uuid',
|
|
'ip_address',
|
|
'gateway',
|
|
'cidr',
|
|
'netmask',
|
|
'module_network_id',
|
|
'gateway',
|
|
'cidr',
|
|
'netmask',
|
|
'status',
|
|
'owner_type',
|
|
'ip_role',
|
|
'parent_ip',
|
|
'customer_name',
|
|
'service_name',
|
|
'allocated_at',
|
|
'revoked_at',
|
|
'allocation_status',
|
|
'contact_email',
|
|
'contact_cc',
|
|
'contact_phone',
|
|
'monthly_cost',
|
|
'selling_price',
|
|
'additional_info',
|
|
'last_email_type',
|
|
'last_email_at',
|
|
'updated_by',
|
|
'note',
|
|
];
|
|
|
|
protected $casts = [
|
|
'allocated_at' => 'date',
|
|
'revoked_at' => 'date',
|
|
'last_email_at' => 'datetime',
|
|
'monthly_cost' => 'decimal:2',
|
|
'selling_price' => 'decimal:2',
|
|
];
|
|
'status',
|
|
'service_id',
|
|
];
|
|
|
|
protected static function boot(): void
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function (self $model) {
|
|
if (empty($model->uuid)) {
|
|
$model->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function network()
|
|
{
|
|
return $this->belongsTo(ModuleNetwork::class, 'module_network_id', 'id');
|
|
}
|
|
|
|
public function service()
|
|
{
|
|
return $this->belongsTo(Service::class, 'service_id');
|
|
}
|
|
|
|
public function virtualMachines()
|
|
{
|
|
return $this->hasMany(VirtualMachines::class, 'ip_pool_id');
|
|
}
|
|
}
|