From b7c94ab7ab539b2f0386db6c4671915e2809a8c0 Mon Sep 17 00:00:00 2001 From: Salah Date: Tue, 4 Jul 2023 10:21:58 +0100 Subject: [PATCH 1/2] Laravel 10 Support --- composer.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 0e83c90..8db7fb0 100644 --- a/composer.json +++ b/composer.json @@ -16,19 +16,19 @@ ], "require": { "php": "^8.1", - "illuminate/support": "^9.0", - "illuminate/console": "^9.0", - "illuminate/database": "^9.0", - "illuminate/broadcasting": "^9.0", - "illuminate/queue": "^9.0", - "illuminate/container": "^9.0" + "illuminate/support": "^9.0|^10.0", + "illuminate/console": "^9.0|^10.0", + "illuminate/database": "^9.0|^10.0", + "illuminate/broadcasting": "^9.0|^10.0", + "illuminate/queue": "^9.0|^10.0", + "illuminate/container": "^9.0|^10.0" }, "require-dev": { - "phpunit/phpunit": "^9.0", - "orchestra/testbench": "^7.1", - "pestphp/pest": "^1.21", - "pestphp/pest-plugin-laravel": "^1.2", - "pestphp/pest-plugin-mock": "^1.0", + "phpunit/phpunit": "^9.0|^10.1", + "orchestra/testbench": "^7.1|^8.5", + "pestphp/pest": "^1.21|2.8", + "pestphp/pest-plugin-laravel": "^1.2|^2.0", + "pestphp/pest-plugin-mock": "^1.0|^2.0", "nunomaduro/larastan": "^2.0" }, "autoload": { From e6696e0d1ed8c1d6ad8d6e84b6fc3bebf52be52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maca=20G=C3=A1rate?= <83234997+mgaratemu@users.noreply.github.com> Date: Sat, 25 Nov 2023 03:14:38 -0300 Subject: [PATCH 2/2] Fix decrementing usages Fix decrementing usages_left when promo is unlimited --- src/Promocodes.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Promocodes.php b/src/Promocodes.php index f97d578..6d34cdf 100644 --- a/src/Promocodes.php +++ b/src/Promocodes.php @@ -251,7 +251,10 @@ public function apply(): ?PromocodeContract event(new GuestAppliedPromocode($this->promocode)); } - $this->promocode->decrement('usages_left'); + if (!$this->promocode->isUnlimited()) { + $this->promocode->decrement('usages_left'); + } + return $this->promocode; }