diff --git a/app/Http/Controllers/Admin/CouponController.php b/app/Http/Controllers/Admin/CouponController.php index c159c42d..d3e32e83 100644 --- a/app/Http/Controllers/Admin/CouponController.php +++ b/app/Http/Controllers/Admin/CouponController.php @@ -28,7 +28,9 @@ class CouponController extends Controller $params['limit_plan_ids'] = json_encode($params['limit_plan_ids']); } if (!$request->input('id')) { - $params['code'] = Helper::randomChar(8); + if (!$params['code']) { + $params['code'] = Helper::randomChar(8); + } if (!Coupon::create($params)) { abort(500, '创建失败'); } diff --git a/app/Http/Requests/Admin/CouponSave.php b/app/Http/Requests/Admin/CouponSave.php index 4be2893f..c7da3e45 100644 --- a/app/Http/Requests/Admin/CouponSave.php +++ b/app/Http/Requests/Admin/CouponSave.php @@ -13,7 +13,8 @@ class CouponSave extends FormRequest 'started_at' => 'required|integer', 'ended_at' => 'required|integer', 'limit_use' => 'nullable|integer', - 'limit_plan_ids' => 'nullable|array' + 'limit_plan_ids' => 'nullable|array', + 'code' => '' ]; /** * Get the validation rules that apply to the request.