* @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function goods(): BelongsTo { return $this->belongsTo(Goods::class); } /** * Notes : 当前规格是否可购买 * * @Date : 2021/5/14 10:08 * @Author : Mr.wang * @param int $qty * @return bool */ public function canBuy(int $qty = 1): bool { if ($this->goods->channel == Goods::CHANNEL_FREE) { return true; } if ($this->goods->status == Goods::STATUS_UP && $this->stock >= $qty) { return true; } return false; } }