QuestionTopic.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Http\Requests\QuestionBank\QuestionReception;
  3. use App\Http\Requests\BaseRequest;
  4. class QuestionTopic extends BaseRequest
  5. {
  6. /**
  7. * 获取应用于请求的规则
  8. *
  9. * @return array
  10. */
  11. public function rules()
  12. {
  13. // 返回结果
  14. return [
  15. //'name' => 'required',
  16. 'id' => 'required|integer|gt:0',
  17. //'status' => 'required|integer|in:0,1',
  18. 'page' => 'integer|min:1',
  19. 'limit' => 'integer|min:1',
  20. 'user_exercise_paper_id' => 'required|integer|gt:0',
  21. 'chapter_id' => 'required|integer|gt:0',
  22. ];
  23. }
  24. // 场景列表
  25. protected $scenes = [
  26. 'list' => ['id', 'page', 'limit', 'user_exercise_paper_id'],
  27. 'set_favorite' => ['id', 'chapter_id'],
  28. 'cancel_favorite' => ['id', 'chapter_id'],
  29. 'answer_topic' => ['id', 'chapter_id'],
  30. 'get_user_exercise_paper' => ['chapter_id'],
  31. 'user_submit_exercise_paper' => ['chapter_id', 'user_exercise_paper_id'],
  32. 'set_user_new_exercise_paper' => ['chapter_id'],
  33. ];
  34. /**
  35. * 获取已定义验证规则的错误消息
  36. *
  37. * @return array
  38. */
  39. public function messages()
  40. {
  41. return [
  42. 'id.required' => 'ID未知',
  43. 'id.integer' => 'ID格式错误',
  44. 'id.gt' => 'ID格式错误',
  45. 'page.integer' => '页码格式错误',
  46. 'page.min' => '页码格式错误',
  47. 'limit.integer' => '每页数量格式错误',
  48. 'limit.min' => '每页数量格式错误',
  49. 'chapter_id.required' => '章节ID未知',
  50. 'chapter_id.integer' => '章节ID格式错误',
  51. 'chapter_id.gt' => '章节ID格式错误',
  52. 'user_exercise_paper_id.required' => '练习册ID未知',
  53. 'user_exercise_paper_id.integer' => '练习册ID格式错误',
  54. 'user_exercise_paper_id.gt' => '练习册ID格式错误',
  55. ];
  56. }
  57. }