From bfab8728af4b459ef233272dbe1790021cb1dba1 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 6 Dec 2017 10:13:21 +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 de509d30e71c..7577e1eab394 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -145,7 +145,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();