input('code'))) { abort(500, '优惠券码不能为空'); } $coupon = Coupon::where('code', $request->input('code'))->first(); if (!$coupon) { abort(500, '优惠券无效'); } if ($coupon->limit_use <= 0) { abort(500, '优惠券已无可用次数'); } if (time() < $coupon->started_at) { abort(500, '优惠券还未到可用时间'); } if (time() > $coupon->ended_at) { abort(500, '优惠券已过期'); } return response([ 'data' => $coupon ]); } }