56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class VPS extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'vps';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'cpu',
|
|
'ram',
|
|
'disk',
|
|
'gpu',
|
|
'description',
|
|
'bandwidth',
|
|
'price',
|
|
'price_sale',
|
|
'module_host_id',
|
|
'template_id',
|
|
'type_id',
|
|
'group_id',
|
|
'status'
|
|
];
|
|
|
|
public function type()
|
|
{
|
|
return $this->belongsTo(\App\Models\Type::class);
|
|
}
|
|
|
|
public function host()
|
|
{
|
|
return $this->belongsTo(\App\Models\ModuleHost::class, 'module_host_id', 'id');
|
|
}
|
|
|
|
public function group()
|
|
{
|
|
return $this->belongsTo(\App\Models\Group::class);
|
|
}
|
|
|
|
/**
|
|
* Many-to-many relationship với OS.
|
|
*/
|
|
public function operatingSystems()
|
|
{
|
|
return $this->belongsToMany(\App\Models\Os::class, 'product_os', 'product_id', 'os_id')
|
|
->withTimestamps()
|
|
->withPivot('product_type');
|
|
}
|
|
}
|