| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Http\Validator;
- class OrderValidator extends BaseValidator
- {
- // 当前模型所有验证规则
- // 当前模型所有错误提示信息
- public static $rules = [
- 'id' => 'required',
- 'goods' => 'required',
- 'num' => 'required|max:10',
- 'order_type' => 'required',
- 'pre_pay_remark' => 'string|max:200',
- 'after_remark' => 'string|max:200',
- ];
- public static $msgs = [
- 'required' => ':attribute不能为空',
- 'string' => ':attribute必须是字符串',
- 'min' => ':attribute长度不能小于:min位',
- 'max' => ':attribute长度不能大于:max位',
- 'exists' => ':attribute不存在',
- 'rule' => ':attribute格式不正确',
- 'mobile' => ':attribute格式不正确',
- ];
- // 当前模型所有验证字段
- public static $fields = [
- 'id' => 'ID',
- 'buy_user_id' => '下单客户',
- 'goods' => '下单商品',
- 'order_type' => '下单类型',
- 'num' => '数量',
- 'pre_pay_remark' => '预付备注',
- 'after_remark' => '售后备注',
- ];
- // 当前模型所有验证场景
- public static $scenes = [
- 'info'=> ['id'],
- 'pay'=> ['id','pay_type'],
- 'cancel'=> ['id','cancel_type'],
- 'receive'=> ['id'],
- 'submit'=> ['goods','order_type','num'],
- ];
- /**
- * 验证
- * @param $request
- * @param string $scene
- * @return int|mixed
- */
- public static function check($request, $scene=''){
- $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes);
- return $validator->checkParams($request, $scene);
- }
- }
|