1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php namespace App\Http\Requests\Admin;
- use App\Http\Requests\BaseRequest;
- /**
- * 积分打卡验证器
- *
- */
- class ScoreClockin extends BaseRequest
- {
- /**
- * 获取应用于请求的规则
- *
- * @return array
- */
- public function rules()
- {
- // 返回结果
- return [
- // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
- // 验证字段,验证规则,提示信息
- 'what_day' => 'required|integer|gt:0|unique:score_clockin,what_day,'.request('id',0),
- 'id' => 'required|integer|gt:0',
- 'status' => 'required|integer|gte:0',
- ];
- }
- // 场景列表
- protected $scenes = [
- 'add' => ['what_day'],
- 'edit' => ['id','days'],
- 'set_status' => ['id','status'],
- ];
- /**
- * 获取已定义验证规则的错误消息
- *
- * @return array
- */
- public function messages()
- {
- return [
- 'what_day.required' => '任务天数必填',
- 'what_day.unique' => '任务天数已存在',
- 'what_day.integer' => '任务天数格式错误',
- 'what_day.gt' => '任务天数格式错误',
- 'id.required' => 'ID未知',
- 'id.integer' => 'ID格式错误',
- 'id.gt' => 'ID格式错误',
- 'status.required' => '状态未知',
- 'status.integer' => '状态格式错误',
- 'status.gte' => '状态格式错误',
- ];
- }
- }
- ?>
|