12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php namespace App\Http\Requests\Api;
- use App\Http\Requests\BaseRequest;
- /**
- * 优惠券验证器
- *
- */
- class Coupon extends BaseRequest
- {
- /**
- * 获取应用于请求的规则
- *
- * @return array
- */
- public function rules()
- {
- // 编辑时排除ID
- // 返回结果
- return [
- // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
- // 验证字段,验证规则,提示信息
- // 'name' => 'string|max:20',
- 'coupon_id' => 'required|integer|gt:0',
- 'page' => 'integer|gte:0',
- 'limit' => 'integer|gte:0',
- ];
- }
- // 场景列表
- protected $scenes = [
- 'get_product' => ['coupon_id','page','limit'],
- ];
- /**
- * 获取已定义验证规则的错误消息
- *
- * @return array
- */
- public function messages()
- {
- return [
- 'coupon_id.required' => '请选择优惠券',
- 'coupon_id.integer' => '优惠券ID格式错误',
- 'coupon_id.gt' => '优惠券ID格式错误',
- 'page.integer' => '页码格式错误',
- 'page.gte' => '页码格式错误',
- 'limit.integer' => '取数格式错误',
- 'limit.gte' => '取数格式错误',
- ];
- }
- }
|