QuestionPoint.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Http\Requests\QuestionBank\QuestionBackend;
  3. use App\Http\Requests\BaseRequest;
  4. class QuestionPoint 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. 'chapter_id' => 'required|integer|gt:0',
  21. 'detail' => 'required',
  22. ];
  23. }
  24. // 场景列表
  25. protected $scenes = [
  26. 'list' => ['page', 'limit'],
  27. 'add' => ['name', 'detail', 'chapter_id'],
  28. 'edit' => ['id', 'name', 'detail', 'chapter_id'],
  29. 'detail' => ['id'],
  30. 'set_status' => ['id', 'status'],
  31. 'delete' => ['id'],
  32. 'get_list_by_chapter' => ['id', 'page', 'limit'],
  33. 'get_list_by_point' => ['id', 'page', 'limit'],
  34. ];
  35. /**
  36. * 获取已定义验证规则的错误消息
  37. *
  38. * @return array
  39. */
  40. public function messages()
  41. {
  42. return [
  43. 'name.required' => '名称必填',
  44. 'id.required' => 'ID未知',
  45. 'id.integer' => 'ID格式错误',
  46. 'id.gt' => 'ID格式错误',
  47. 'page.integer' => '页码格式错误',
  48. 'page.min' => '页码格式错误',
  49. 'limit.integer' => '每页数量格式错误',
  50. 'limit.min' => '每页数量格式错误',
  51. 'chapter_id.required' => '科目ID未知',
  52. 'chapter_id.integer' => '科目ID格式错误',
  53. 'chapter_id.gt' => '科目ID格式错误',
  54. 'detail.required' => '考点内容必填',
  55. 'status.required' => '状态未知',
  56. 'status.integer' => '状态格式错误',
  57. 'status.in' => '状态格式错误',
  58. ];
  59. }
  60. }