added vocher validation
This commit is contained in:
@@ -18,6 +18,7 @@ use App\Traits\CaptchaTrait;
|
|||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
use Illuminate\Support\Facades\Redirect;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class TeamStoreController extends Controller
|
class TeamStoreController extends Controller
|
||||||
{
|
{
|
||||||
@@ -699,7 +700,7 @@ class TeamStoreController extends Controller
|
|||||||
);
|
);
|
||||||
|
|
||||||
$getVoucher = $TeamStoreModel->selectVoucher($data);
|
$getVoucher = $TeamStoreModel->selectVoucher($data);
|
||||||
|
$now = Carbon::now();
|
||||||
if ($getVoucher) {
|
if ($getVoucher) {
|
||||||
$items = $TeamStoreModel->myCart($cartKey);
|
$items = $TeamStoreModel->myCart($cartKey);
|
||||||
|
|
||||||
@@ -711,6 +712,20 @@ class TeamStoreController extends Controller
|
|||||||
'message' => 'This voucher is already in used.'
|
'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
|
// insert vocuher to cart_tmp
|
||||||
|
|||||||
Reference in New Issue
Block a user