Update source into github
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Os extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'os';
|
||||
|
||||
protected $fillable = [
|
||||
'version',
|
||||
'os_id',
|
||||
'module_host_id',
|
||||
'os_group_id',
|
||||
'template_id',
|
||||
'vcenter_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function osGroup()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\OsGroup::class);
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']){
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-danger">De-Active</span>'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Many-to-many relationship với VPS products.
|
||||
*/
|
||||
public function vpsProducts()
|
||||
{
|
||||
return $this->belongsToMany(\App\Models\VPS::class, 'product_os', 'os_id', 'product_id')
|
||||
->withTimestamps()
|
||||
->withPivot('product_type');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user