UserShareForms.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Http\Requests\QuestionBank\QuestionBackend;
  3. use App\Http\Requests\BaseRequest;
  4. /**
  5. * 用户分享报表接口验证
  6. * @author 唐远望
  7. * @version 1.0
  8. * @date 2025-05-21
  9. *
  10. */
  11. class UserShareForms extends BaseRequest
  12. {
  13. /**
  14. * 获取应用于请求的规则
  15. *
  16. * @return array
  17. */
  18. public function rules()
  19. {
  20. // 返回结果
  21. return [
  22. 'name' => 'required',
  23. 'id' => 'required|integer|gt:0',
  24. 'status' => 'required|integer|in:0,1',
  25. 'page' => 'integer|min:1',
  26. 'limit' => 'integer|min:1',
  27. 'allow_unlocking_chapter_count' => 'integer|min:0',
  28. 'number_of_unlocked_chapters' => 'integer|min:0',
  29. 'number_of_invitations' => 'integer|min:0',
  30. 'unlocked_courses_user_number' => 'integer|min:0',
  31. ];
  32. }
  33. // 场景列表
  34. protected $scenes = [
  35. 'detail' => ['id'],
  36. 'list' => ['page', 'limit'],
  37. 'add' => ['allow_unlocking_chapter_count', 'number_of_unlocked_chapters', 'number_of_invitations', 'unlocked_courses_user_number'],
  38. 'edit' => ['id','allow_unlocking_chapter_count', 'number_of_unlocked_chapters', 'number_of_invitations', 'unlocked_courses_user_number'],
  39. 'set_status' => ['id', 'status'],
  40. 'delete' => ['id'],
  41. ];
  42. /**
  43. * 获取已定义验证规则的错误消息
  44. *
  45. * @return array
  46. */
  47. public function messages()
  48. {
  49. return [
  50. 'name.required' => '名称必填',
  51. 'id.required' => 'ID未知',
  52. 'id.integer' => 'ID格式错误',
  53. 'id.gt' => 'ID格式错误',
  54. 'status.required' => '状态未知',
  55. 'status.integer' => '状态格式错误',
  56. 'status.in' => '状态格式错误',
  57. 'page.integer' => '页码格式错误',
  58. 'page.min' => '页码格式错误',
  59. 'limit.integer' => '每页数量格式错误',
  60. 'limit.min' => '每页数量格式错误',
  61. 'allow_unlocking_chapter_count.integer' => '可解锁章节数格式错误',
  62. 'allow_unlocking_chapter_count.min' => '可解锁章节数格式错误',
  63. 'number_of_unlocked_chapters.integer' => '已解锁章节数量格式错误',
  64. 'number_of_unlocked_chapters.min' => '已解锁章节数量格式错误',
  65. 'number_of_invitations.integer' => '邀请数量格式错误',
  66. 'number_of_invitations.min' => '邀请数量格式错误',
  67. 'unlocked_courses_user_number.integer' => '已解锁课程人数格式错误',
  68. 'unlocked_courses_user_number.min' => '已解锁课程人数格式错误',
  69. ];
  70. }
  71. }