feat: Enhance product support in Cart and OrderItem models
- 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.
This commit is contained in:
@@ -25,6 +25,15 @@ class OrderItem extends Model
|
||||
|
||||
public function getProductAttribute()
|
||||
{
|
||||
// New flow: Check if product exists in Product table first
|
||||
if ($this->product_id) {
|
||||
$product = Product::find($this->product_id);
|
||||
if ($product) {
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy flow: fallback to old system
|
||||
return match ($this->product_type) {
|
||||
3 => Hosting::find($this->product_id),
|
||||
4 => Vps::find($this->product_id),
|
||||
@@ -32,6 +41,22 @@ class OrderItem extends Model
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: OrderItem belongs to Product (new system)
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: OrderItem has pricing info
|
||||
*/
|
||||
public function pricing()
|
||||
{
|
||||
return $this->belongsTo(ProductPricings::class, 'product_pricing_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function os()
|
||||
|
||||
Reference in New Issue
Block a user