47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\LogsActivity;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ModuleIpAddress extends Model
|
|
{
|
|
use HasFactory, LogsActivity;
|
|
|
|
protected $table = 'module_ip_address';
|
|
|
|
protected $fillable = [
|
|
'vm_name',
|
|
'module_host_id',
|
|
'module_network_id',
|
|
'ip',
|
|
'gateway',
|
|
'netmask',
|
|
'dns',
|
|
'status'
|
|
];
|
|
public function host()
|
|
{
|
|
return $this->belongsTo(\App\Models\ModuleHost::class,'module_host_id','id');
|
|
}
|
|
public function network()
|
|
{
|
|
return $this->belongsTo(\App\Models\ModuleNetwork::class,'module_network_id','id');
|
|
|
|
}
|
|
public function scopeIsFree(Builder $query)
|
|
{
|
|
$query->where('status',0);
|
|
}
|
|
public function getStatus()
|
|
{
|
|
return match($this->attributes['status']) {
|
|
1 => '<span class="badge badge-info">Assigned</span>',
|
|
default => '<span class="badge bg-success">Free</span>'
|
|
};
|
|
}
|
|
}
|