'boolean', ]; public function products(): HasMany { return $this->hasMany(Product::class); } public function activeProducts(): HasMany { return $this->hasMany(Product::class)->where('is_active', true); } public function getProductsCountAttribute(): int { return $this->activeProducts()->count(); } public function scopeActive($query) { return $query->where('is_active', true); } public function scopePopular($query) { return $query->withCount('products')->orderBy('products_count', 'desc'); } public function getLogoUrlAttribute(): string { if ($this->logo) { $logoPath = 'assets/images/brands/' . $this->logo; if (file_exists(public_path($logoPath))) { return asset($logoPath); } } return asset('assets/images/brands/default.svg'); } }