input('code'))) { return $this->fail([422,__('Coupon cannot be empty')]); } $couponService = new CouponService($request->input('code')); $couponService->setPlanId($request->input('plan_id')); $couponService->setUserId($request->user['id']); $couponService->check(); return $this->success($couponService->getCoupon()); } }