update
This commit is contained in:
+42
-3
@@ -17,19 +17,58 @@ class Product extends Model
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'short_description',
|
||||
'description',
|
||||
'price',
|
||||
'price_sale',
|
||||
'billing_cycle',
|
||||
'setup_fee',
|
||||
'trial_days',
|
||||
'cpu',
|
||||
'ram',
|
||||
'gpu',
|
||||
'disk',
|
||||
'bandwidth',
|
||||
'stock',
|
||||
'is_unlimited',
|
||||
'is_active',
|
||||
'sort_order',
|
||||
'product_type',
|
||||
'product_categories_id',
|
||||
'published_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'is_unlimited' => 'boolean',
|
||||
'published_at' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relationship: Product belongs to a Category
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ProductCategories::class, 'product_categories_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Product has many OS versions (pivot table: os_product)
|
||||
*/
|
||||
public function osVersions()
|
||||
{
|
||||
return $this->belongsToMany(Os::class, 'os_product', 'product_id', 'os_id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Product has many pricings
|
||||
*/
|
||||
public function pricings()
|
||||
{
|
||||
return $this->hasMany(ProductPricings::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy: Many-to-many categories (if still needed)
|
||||
*/
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany(ProductCategories::class, 'product_product_category', 'product_id', 'product_category_id');
|
||||
|
||||
Reference in New Issue
Block a user