feat: create PostCategoryFactory for generating post category data feat: create PostFactory for generating post data feat: add retry_requested_at column to services table feat: add vcenter provisioning fields to products table feat: add module_host_id to os table feat: create email_notification_templates table for email templates feat: add scenario and format fields to template table feat: add admin fields to transactions table fix: update ticket table columns and types feat: add uuid to ticket table and backfill existing records fix: make ticket_reply user_id nullable feat: create notifications table for user notifications fix: make ticket uuid nullable feat: create post_categories table for blog categories feat: create posts table for blog posts feat: add invoice email template for PDF generation
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?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_group_id',
|
|
'template_id',
|
|
'module_host_id',
|
|
'status',
|
|
];
|
|
|
|
public function osGroup()
|
|
{
|
|
return $this->belongsTo(\App\Models\OsGroup::class);
|
|
}
|
|
|
|
public function host()
|
|
{
|
|
return $this->belongsTo(\App\Models\ModuleHost::class, 'module_host_id');
|
|
}
|
|
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 Products (new table: os_product)
|
|
*/
|
|
public function products()
|
|
{
|
|
return $this->belongsToMany(\App\Models\Product::class, 'os_product', 'os_id', 'product_id')
|
|
->withTimestamps();
|
|
}
|
|
|
|
/**
|
|
* Get display name with OS Group
|
|
*/
|
|
public function getNameAttribute()
|
|
{
|
|
if ($this->osGroup) {
|
|
return $this->osGroup->name . ' ' . $this->version;
|
|
}
|
|
return $this->version;
|
|
}
|
|
}
|