From aa27685e7756918976ab61a2e5177b49ef2baa9d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 6 Dec 2017 10:12:52 +0200 Subject: [PATCH] Fix promotion --- app/Models/Company.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index cd02126ac249..ddb01766aa54 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -140,7 +140,7 @@ class Company extends Eloquent foreach ($discounts as $weeks => $promo) { list($discount, $validFor) = $promo; $difference = $this->created_at->diffInWeeks(); - if ($difference >= $weeks) { + if ($difference >= $weeks && $discount > $this->discount) { $this->discount = $discount; $this->promo_expires = date_create()->modify($validFor . ' days')->format('Y-m-d'); $this->save();