fix structure product categories table and crud product

This commit is contained in:
2025-06-02 16:21:33 +07:00
parent 59e23ae535
commit 6bf8bc4965
21 changed files with 573 additions and 141 deletions

View File

@@ -10,9 +10,17 @@ class ProductCategory extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = ['name'];
protected $fillable = ['name','parent_id'];
public function products(){
return $this->hasMany(Product::class, 'product_category_id');
}
public function parent(){
return $this->belongsTo(ProductCategory::class, 'parent_id');
}
public function children(){
return $this->hasMany(ProductCategory::class,'parent_id');
}
}