*/ use HasFactory; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'category_id', 'brand_id', 'name', 'slug', 'sku', 'short_description', 'description', 'thumbnail_path', 'price', 'stock_quantity', 'active', 'published_at', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'price' => 'decimal:2', 'active' => 'boolean', 'published_at' => 'datetime', ]; } public function category(): BelongsTo { return $this->belongsTo(Category::class); } public function brand(): BelongsTo { return $this->belongsTo(Brand::class); } #[Scope] protected function active(Builder $query) : void { $query->where('active', 1); } }