Topic.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Http\Requests\Community\CommReception;
  3. use App\Http\Requests\BaseRequest;
  4. /**
  5. * 帖子接口验证
  6. * @author 唐远望
  7. * @version 1.0
  8. * @date 2025-04-17
  9. *
  10. */
  11. class Topic 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. 'title' => 'required',
  28. 'content' => 'required',
  29. 'type_id' => 'required|integer|gt:0',
  30. 'content_type' => 'required|integer|in:1,2',
  31. 'topic_id' => 'required|integer|gt:0',
  32. 'status' => 'in:5,1',
  33. ];
  34. }
  35. // 场景列表
  36. protected $scenes = [
  37. 'detail' => ['id'],
  38. 'list' => ['page', 'limit'],
  39. 'top_list' => ['page', 'limit'],
  40. 'add' => ['title', 'content', 'type_id', 'content_type','status'],
  41. 'edit' => ['id','status'],
  42. 'set_status' => ['id', 'status'],
  43. 'delete' => ['id'],
  44. 'set_like' => ['id'],
  45. 'cancel_like' => ['id'],
  46. 'set_dislike' => ['id'],
  47. 'cancel_dislike' => ['id'],
  48. 'my_list' => ['page', 'limit'],
  49. ];
  50. /**
  51. * 获取已定义验证规则的错误消息
  52. *
  53. * @return array
  54. */
  55. public function messages()
  56. {
  57. return [
  58. 'name.required' => '名称必填',
  59. 'id.required' => 'ID未知',
  60. 'id.integer' => 'ID格式错误',
  61. 'id.gt' => 'ID格式错误',
  62. 'status.required' => '状态未知',
  63. 'status.integer' => '状态格式错误',
  64. 'status.in' => '状态格式错误',
  65. 'page.integer' => '页码格式错误',
  66. 'page.min' => '页码格式错误',
  67. 'limit.integer' => '每页数量格式错误',
  68. 'limit.min' => '每页数量格式错误',
  69. 'title.required' => '标题必填',
  70. 'content.required' => '内容必填',
  71. 'type_id.required' => '分类未知',
  72. 'type_id.integer' => '分类格式错误',
  73. 'type_id.gt' => '分类格式错误',
  74. 'content_type.required' => '内容类型未知',
  75. 'content_type.integer' => '内容类型格式错误',
  76. 'content_type.in' => '内容类型格式错误',
  77. 'topic_id.required' => '帖子ID未知',
  78. 'topic_id.integer' => '帖子ID格式错误',
  79. 'topic_id.gt' => '帖子ID格式错误'
  80. ];
  81. }
  82. }