ProductStatus::class, 'is_featured' => 'boolean', ]; } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logAll() ->logOnlyDirty() ->dontLogEmptyChanges(); } protected function formattedName(): Attribute { return Attribute::make( get: fn () => ucfirst($this->name), ); } protected function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status?->label(), ); } #[Scope] protected function active(Builder $query): void { $query->where('status', ProductStatus::ACTIVE); } #[Scope] protected function draft(Builder $query): void { $query->where('status', ProductStatus::DRAFT); } #[Scope] protected function featured(Builder $query): void { $query->where('is_featured', true); } #[Scope] protected function inactive(Builder $query): void { $query->where('status', ProductStatus::INACTIVE); } #[Scope] protected function pending(Builder $query): void { $query->where('status', ProductStatus::PENDING); } #[Scope] protected function rejected(Builder $query): void { $query->where('status', ProductStatus::REJECTED); } public function categories(): BelongsToMany { return $this->belongsToMany(Category::class, 'product_categories') ->using(ProductCategory::class); } public function productVariants(): HasMany { return $this->hasMany(ProductVariant::class); } }