Product.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Http\Requests\Company\Promoter;
  3. use App\Http\Requests\BaseRequest;
  4. use Illuminate\Validation\Rule;
  5. /**
  6. * 推广员商品接口验证
  7. * @author 唐远望
  8. * @version 1.0
  9. * @date 2025-09-08
  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. 'page' => 'integer|min:1',
  26. 'limit' => 'integer|min:1',
  27. 'status ' => 'integer|in:0,1',
  28. 'promoter_userid' => 'required',
  29. 'product_ids' => 'required|string',
  30. 'product_id' => 'required|integer|gt:0',
  31. ];
  32. return $rules;
  33. }
  34. // 场景列表
  35. protected $scenes = [
  36. 'add' => ['promoter_userid','product_ids'],
  37. 'list' => ['page', 'limit'],
  38. 'detail' => ['id'],
  39. 'set_status' => ['id', 'status'],
  40. 'set_commission' => ['id', 'mini_commission_rate','live_commission_rate'],
  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. 'promoter_userid.required' => '推广员ID未知',
  62. 'product_ids.required' => '商品ID未知',
  63. 'product_ids.string' => '商品ID格式错误',
  64. 'product_id.required' => '商品ID未知',
  65. 'product_id.integer' => '商品ID格式错误',
  66. 'product_id.gt' => '商品ID格式错误',
  67. ];
  68. }
  69. }