PlayQuestion.php 1.6 KB

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