add custom coupon code

This commit is contained in:
Tokumeikoi 2020-06-20 00:50:21 +08:00
parent 80e6fb7186
commit 6324645f08
2 changed files with 5 additions and 2 deletions

View File

@ -28,7 +28,9 @@ class CouponController extends Controller
$params['limit_plan_ids'] = json_encode($params['limit_plan_ids']); $params['limit_plan_ids'] = json_encode($params['limit_plan_ids']);
} }
if (!$request->input('id')) { if (!$request->input('id')) {
$params['code'] = Helper::randomChar(8); if (!$params['code']) {
$params['code'] = Helper::randomChar(8);
}
if (!Coupon::create($params)) { if (!Coupon::create($params)) {
abort(500, '创建失败'); abort(500, '创建失败');
} }

View File

@ -13,7 +13,8 @@ class CouponSave extends FormRequest
'started_at' => 'required|integer', 'started_at' => 'required|integer',
'ended_at' => 'required|integer', 'ended_at' => 'required|integer',
'limit_use' => 'nullable|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. * Get the validation rules that apply to the request.