QuestionRealTopic.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Http\Requests\QuestionBank\QuestionBackend;
  3. use App\Http\Requests\BaseRequest;
  4. class QuestionRealTopic extends BaseRequest
  5. {
  6. /**
  7. * 获取应用于请求的规则
  8. *
  9. * @return array
  10. */
  11. public function rules()
  12. {
  13. // 返回结果
  14. return [
  15. 'title' => 'required',
  16. 'id' => 'required|integer|gt:0',
  17. 'question_count' => 'required|integer|gt:0',
  18. 'style' => 'required|integer|in:2,3,6',
  19. 'page' => 'integer|min:1',
  20. 'limit' => 'integer|min:1',
  21. //'chapter_id' => 'required|integer|gt:0',
  22. 'correct_answer' => 'required',
  23. 'explain' => 'required',
  24. 'is_high_freq' => 'required|integer|in:0,1',
  25. ];
  26. }
  27. // 场景列表
  28. protected $scenes = [
  29. 'list' => ['page', 'limit'],
  30. //'add' => ['title', 'style', 'chapter_id', 'correct_answer', 'explain', 'question_count'],
  31. 'edit' => ['id', 'title', 'style', 'correct_answer', 'explain', 'question_count'],
  32. 'detail' => ['id'],
  33. 'set_high_freq' => ['id', 'is_high_freq'],
  34. ];
  35. /**
  36. * 获取已定义验证规则的错误消息
  37. *
  38. * @return array
  39. */
  40. public function messages()
  41. {
  42. return [
  43. 'title.required' => '标题必填',
  44. 'explain.required' => '题目解析必填',
  45. 'correct_answer.required' => '正确答案必填',
  46. 'id.required' => 'ID未知',
  47. 'id.integer' => 'ID格式错误',
  48. 'id.gt' => 'ID必须大于0',
  49. 'page.integer' => '页码格式错误',
  50. 'page.min' => '页码格式错误',
  51. 'limit.integer' => '每页数量格式错误',
  52. 'limit.min' => '每页数量格式错误',
  53. // 'chapter_id.required' => '科目ID未知',
  54. // 'chapter_id.integer' => '科目ID格式错误',
  55. // 'chapter_id.gt' => '科目ID必须大于0',
  56. 'detail.required' => '考点内容必填',
  57. 'style.required' => '题目类型未知',
  58. 'style.integer' => '题目类型格式错误',
  59. 'style.in' => '题目类型格式错误',
  60. 'question_count.required' => '选项数量未知',
  61. 'question_count.integer' => '选项数量格式错误',
  62. 'question_count.gt' => '选项数量必须大于0',
  63. 'is_high_freq.required' => '是否高频考题未知',
  64. 'is_high_freq.integer' => '是否高频考题格式错误',
  65. 'is_high_freq.in' => '是否高频考题格式错误',
  66. ];
  67. }
  68. }