'decimal:2', 'retail_price' => 'decimal:2', 'cost_price' => 'decimal:2', 'packaging_cost' => 'decimal:2', 'shipping_packaging_cost' => 'decimal:2', 'volume' => 'decimal:2', 'length' => 'decimal:2', 'width' => 'decimal:2', 'height' => 'decimal:2', 'batch_management' => 'boolean', ]; /** * 关联品牌 */ public function brand() { return $this->belongsTo(Brand::class); } /** * 关联供应商(多对多) */ public function suppliers() { return $this->belongsToMany(Supplier::class, 'goods_supplier'); } /** * 如果是组合商品,关联子商品 */ public function comboItems() { return $this->hasMany(ComboItem::class, 'combo_goods_id'); } /** * 作为子商品时,被哪些组合商品包含 */ public function parentCombos() { return $this->belongsToMany(Goods::class, 'combo_items', 'goods_id', 'combo_goods_id') ->withPivot('quantity'); } }