FleetCart/Modules/Cart/Http/Middleware/CheckCouponUsageLimit.php
2023-06-11 13:14:03 +01:00

28 lines
647 B
PHP

<?php
namespace Modules\Cart\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Modules\Cart\Facades\Cart;
use Modules\Coupon\Exceptions\CouponUsageLimitReachedException;
class CheckCouponUsageLimit
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (Cart::coupon()->usageLimitReached($request->customer_email)) {
throw new CouponUsageLimitReachedException;
}
return $next($request);
}
}