- Added new fields 'billing_cycle' and 'product_pricing_id' to Cart and OrderItem models. - Updated product retrieval logic to support both new and legacy systems. - Introduced relationships for Product and ProductPricings in Cart and OrderItem models. - Created migration to add new fields to the carts and order_item tables. - Updated frontend service index to handle new pricing structure and billing cycles. - Improved UI components for better user experience in product selection and pricing display. - Refactored action buttons in various views for consistency and improved styling.
63 lines
1.4 KiB
PHP
63 lines
1.4 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',
|
|
'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');
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|