Fix promotion

This commit is contained in:
Hillel Coren 2017-12-06 10:12:52 +02:00
parent d13629913e
commit aa27685e77

View File

@ -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();