*/ use HasFactory; protected $fillable = [ 'name', 'slug', 'icon', 'sort_order', 'is_active', ]; protected function casts(): array { return [ 'is_active' => 'boolean', 'sort_order' => 'integer', ]; } protected static function booted(): void { static::saving(function (Category $category): void { if (empty($category->slug)) { $category->slug = Str::slug($category->name); } }); } public function products(): HasMany { return $this->hasMany(Product::class); } public function scopeActive($query): void { $query->where('is_active', true); } }