getKey()) * ->where('available_copies', '>=', $quantity) * ->update(['available_copies' => DB::raw('available_copies - '.$quantity)]); * } * * Host model still needs to declare `implements Cartable, Purchasable` — * the trait satisfies the contract methods but cannot apply interfaces. */ trait IsSimplePurchasable { /** @return MorphMany */ public function purchases(): MorphMany { $purchaseModel = config('shop.models.product_purchase', ProductPurchase::class); return $this->morphMany($purchaseModel, 'purchasable'); } public function getCurrentPrice(): ?float { return 0.0; } public function getPriceAttribute(): ?float { return 0.0; } public function isOnSale(): bool { return false; } public function decreaseStock(int $quantity = 1): bool { return true; } public function increaseStock(int $quantity = 1): bool { return true; } }