Product.php 1.9 KB

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