From 7a4ba9c289efc92804989a30cc9566c7345fcd26 Mon Sep 17 00:00:00 2001 From: andreich1980 Date: Tue, 18 Jul 2017 11:27:42 +0300 Subject: [PATCH] Update Promocodes.php Now `apply` method marks promocode as `used`, fills `is_used` with `Carbon::now()`. Wonder why it was commented out? --- src/Model/Promocodes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Promocodes.php b/src/Model/Promocodes.php index bea366b..5c6efaa 100644 --- a/src/Model/Promocodes.php +++ b/src/Model/Promocodes.php @@ -210,7 +210,7 @@ public function check($code) public function apply($code, $hard_check = false) { $record = Promocodes::where('code', $code) - // ->whereNull('is_used') + ->whereNull('is_used') ->where('quantity', '!=' , 0) // -1 for infinite ->where(function($q) { $q->whereDate('expiry_date', '<' , Carbon::today()) @@ -222,7 +222,7 @@ public function apply($code, $hard_check = false) if ($record->quantity > 0) { $record->quantity--; } - // $record->is_used = date('Y-m-d H:i:s'); + $record->is_used = Carbon::now(); if ($record->save()) { if ($hard_check) {