|
|
@@ -1,55 +0,0 @@
|
|
|
-<?php
|
|
|
-namespace App\Http\Validator;
|
|
|
-class StoreValidator extends BaseValidator
|
|
|
-{
|
|
|
- // 当前模型所有验证规则
|
|
|
- public static $rules = [
|
|
|
- 'id' => 'required',
|
|
|
- 'name' => 'required|max:100',
|
|
|
- 'real_name' => 'required|max:20',
|
|
|
- 'phone' => 'required|mobile|max:30',
|
|
|
- 'address' => 'required|max:200',
|
|
|
- 'category_id' => 'required|max:10',
|
|
|
- 'logo' => 'required|max:250',
|
|
|
- 'business_license' => 'required|max:250',
|
|
|
- ];
|
|
|
- public static $msgs = [
|
|
|
- 'required' => ':attribute不能为空',
|
|
|
- 'string' => ':attribute必须是字符串',
|
|
|
- 'min' => ':attribute长度不能小于:min位',
|
|
|
- 'max' => ':attribute长度不能大于:max位',
|
|
|
- 'exists' => ':attribute不存在',
|
|
|
- 'rule' => ':attribute格式不正确',
|
|
|
- 'mobile' => ':attribute格式不正确',
|
|
|
- ];
|
|
|
-
|
|
|
- // 当前模型所有验证字段
|
|
|
- public static $fields = [
|
|
|
- 'id' => 'ID',
|
|
|
- 'name' => '店铺名称',
|
|
|
- 'real_name' => '姓名',
|
|
|
- 'phone' => '电话',
|
|
|
- 'address' => '店铺地址',
|
|
|
- 'category_id' => '行业分类',
|
|
|
- 'logo' => '店铺门头',
|
|
|
- 'business_license' => '营业执照',
|
|
|
- ];
|
|
|
-
|
|
|
- // 当前模型所有验证场景
|
|
|
- public static $scenes = [
|
|
|
- 'apply'=> ['name','real_name','phone','address','category_id','business_license','logo'],
|
|
|
- 'save'=> ['id','name','real_name','phone','address','category_id','business_license','logo'],
|
|
|
- 'del'=> ['id'],
|
|
|
- ];
|
|
|
-
|
|
|
- /**
|
|
|
- * 验证
|
|
|
- * @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);
|
|
|
- }
|
|
|
-}
|