feat: introduce ProductCategoryResource and refactor database migrations by deleting old tables and consolidating transaction schema.

This commit is contained in:
pbao9
2026-02-18 21:44:31 +07:00
parent 9a2cab4521
commit 75791d6257
12 changed files with 76 additions and 163 deletions
+15 -1
View File
@@ -32,7 +32,6 @@ class Product extends Model
'is_unlimited',
'is_active',
'sort_order',
'product_type',
'product_categories_id',
'published_at',
];
@@ -42,8 +41,23 @@ class Product extends Model
'is_unlimited' => 'boolean',
'published_at' => 'date',
'gallery' => 'array',
'product_type' => 'string',
];
protected static function boot()
{
parent::boot();
static::saving(function ($product) {
if ($product->product_categories_id) {
$category = ProductCategories::find($product->product_categories_id);
if ($category && $category->type) {
$product->product_type = $category->type;
}
}
});
}
/**
* Relationship: Product belongs to a Category
*/