为什么 decreaseStock 需要用 where 来判断 id? 而 addStock 不需要呢
public function decreaseStock($amount) {
if ($amount < 0) {
throw new InternalException('减库存不可小于0');
}
return $this->where('id', $this->id)->where('stock','>=',$amount)->decrement('stock', $amount); }
推荐文章: