ScoreClockin.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php namespace App\Http\Requests\Admin;
  2. use App\Http\Requests\BaseRequest;
  3. /**
  4. * 积分打卡验证器
  5. *
  6. */
  7. class ScoreClockin extends BaseRequest
  8. {
  9. /**
  10. * 获取应用于请求的规则
  11. *
  12. * @return array
  13. */
  14. public function rules()
  15. {
  16. // 返回结果
  17. return [
  18. // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
  19. // 验证字段,验证规则,提示信息
  20. 'what_day' => 'required|integer|gt:0|unique:score_clockin,what_day,'.request('id',0),
  21. 'id' => 'required|integer|gt:0',
  22. 'status' => 'required|integer|gte:0',
  23. ];
  24. }
  25. // 场景列表
  26. protected $scenes = [
  27. 'add' => ['what_day'],
  28. 'edit' => ['id','days'],
  29. 'set_status' => ['id','status'],
  30. ];
  31. /**
  32. * 获取已定义验证规则的错误消息
  33. *
  34. * @return array
  35. */
  36. public function messages()
  37. {
  38. return [
  39. 'what_day.required' => '任务天数必填',
  40. 'what_day.unique' => '任务天数已存在',
  41. 'what_day.integer' => '任务天数格式错误',
  42. 'what_day.gt' => '任务天数格式错误',
  43. 'id.required' => 'ID未知',
  44. 'id.integer' => 'ID格式错误',
  45. 'id.gt' => 'ID格式错误',
  46. 'status.required' => '状态未知',
  47. 'status.integer' => '状态格式错误',
  48. 'status.gte' => '状态格式错误',
  49. ];
  50. }
  51. }
  52. ?>