added voucher validation
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Models\user\UserModel;
|
||||
// use Mail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Analytics;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class TeamStoreController extends Controller
|
||||
@@ -680,7 +681,7 @@ class TeamStoreController extends Controller
|
||||
);
|
||||
|
||||
$getVoucher = $TeamStoreModel->selectVoucher($data);
|
||||
|
||||
$now = Carbon::now();
|
||||
if ($getVoucher) {
|
||||
$items = $TeamStoreModel->myCart($cartKey);
|
||||
|
||||
@@ -692,6 +693,20 @@ class TeamStoreController extends Controller
|
||||
'message' => 'This voucher is already in used.'
|
||||
));
|
||||
}
|
||||
|
||||
if ($getVoucher[0]->Status == 'Inactive') {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => 'This voucher is inactive.'
|
||||
));
|
||||
}
|
||||
|
||||
if ($getVoucher[0]->VoucherExpiryDate < $now) {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => 'This voucher has expired.'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// insert vocuher to cart_tmp
|
||||
|
||||
Reference in New Issue
Block a user