TopicRule.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php namespace App\Http\Requests\Community\CommReception;
  2. use App\Http\Requests\BaseRequest;
  3. /**
  4. * 帖子规则验证器
  5. * @author 唐远望
  6. * @version 1.0
  7. * @date 2025-04-11
  8. *
  9. */
  10. class TopicRule extends BaseRequest
  11. {
  12. /**
  13. * 获取应用于请求的规则
  14. *
  15. * @return array
  16. */
  17. public function rules()
  18. {
  19. // 返回结果
  20. return [
  21. 'name' => 'required',
  22. 'id' => 'required|integer|gt:0',
  23. 'status' => 'required|integer|in:0,1',
  24. 'page' => 'integer|min:1',
  25. 'limit' => 'integer|min:1',
  26. ];
  27. }
  28. // 场景列表
  29. protected $scenes = [
  30. 'detail' => ['id'],
  31. 'list' => ['page','limit'],
  32. 'add' => ['name'],
  33. 'edit' => ['id','name'],
  34. 'set_status' => ['id','status'],
  35. 'delete' => ['id'],
  36. ];
  37. /**
  38. * 获取已定义验证规则的错误消息
  39. *
  40. * @return array
  41. */
  42. public function messages()
  43. {
  44. return [
  45. 'name.required' => '名称必填',
  46. 'id.required' => 'ID未知',
  47. 'id.integer' => 'ID格式错误',
  48. 'id.gt' => 'ID格式错误',
  49. 'status.required' => '状态未知',
  50. 'status.integer' => '状态格式错误',
  51. 'status.in' => '状态格式错误',
  52. 'page.integer' => '页码格式错误',
  53. 'page.min' => '页码格式错误',
  54. 'limit.integer' => '每页数量格式错误',
  55. 'limit.min' => '每页数量格式错误',
  56. ];
  57. }
  58. }