belongsTo(\App\Models\OsGroup::class); } public function getStatus() { return match ($this->attributes['status']){ 1 => 'Active', default => 'De-Active' }; } /** * 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'); } /** * 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; } }