¨4.0.1¨
This commit is contained in:
@@ -38,19 +38,22 @@ class FlashSaleProduct extends Pivot
|
||||
*/
|
||||
protected $appends = ['sold'];
|
||||
|
||||
|
||||
public function getSoldAttribute()
|
||||
{
|
||||
return $this->orders()->sum('qty');
|
||||
}
|
||||
|
||||
public function getPriceAttribute($price)
|
||||
{
|
||||
return Money::inDefaultCurrency($price);
|
||||
}
|
||||
|
||||
public function orders()
|
||||
{
|
||||
return $this->belongsToMany(Order::class, 'flash_sale_product_orders', 'flash_sale_product_id')
|
||||
->withPivot('qty');
|
||||
}
|
||||
|
||||
|
||||
public function getPriceAttribute($price)
|
||||
{
|
||||
return Money::inDefaultCurrency($price);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user