Topic.php 2.7 KB

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