BuyControllerValidate.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace App\Http\Validate\Buy;
  3. use App\Http\Validate\BaseValidate;
  4. use Illuminate\Support\Facades\Validator;
  5. class BuyControllerValidate extends BaseValidate
  6. {
  7. /**
  8. * 电商平台分类列表参数校验
  9. * @param $data
  10. * @return bool
  11. */
  12. public function getCateList($data)
  13. {
  14. $validate = Validator::make($data,
  15. [
  16. "source"=>"required",
  17. ]
  18. );
  19. if($validate->fails()){
  20. //验证错误
  21. $this->setError($validate->errors()->first());
  22. return false;
  23. }
  24. return true;
  25. }
  26. /**
  27. * 商品列表参数校验
  28. * @param $data
  29. */
  30. public function getGoodsList($data)
  31. {
  32. $validate = Validator::make($data,
  33. [
  34. "source"=>"required",
  35. "cat_id"=>"required|integer",
  36. "page"=>"required|integer",
  37. "page_size"=>"required|integer",
  38. ]
  39. );
  40. if($validate->fails()){
  41. //验证错误
  42. $this->setError($validate->errors()->first());
  43. return false;
  44. }
  45. return true;
  46. }
  47. /**
  48. * 商品详情页参数校验
  49. * @param $data
  50. */
  51. public function getGoodsDetail($data)
  52. {
  53. $validate = Validator::make($data,
  54. [
  55. "source"=>"required",
  56. "goods_id"=>"required",
  57. ]
  58. );
  59. if($validate->fails()){
  60. //验证错误
  61. $this->setError($validate->errors()->first());
  62. return false;
  63. }
  64. return true;
  65. }
  66. /**
  67. * 搜索商品参数校验
  68. * @param $data
  69. */
  70. public function getGoodsSearch($data)
  71. {
  72. $validate = Validator::make($data,
  73. [
  74. "source"=>"required",
  75. "keyword"=>"required",
  76. "page"=>"required",
  77. "page_size"=>"required",
  78. ]
  79. );
  80. if($validate->fails()){
  81. //验证错误
  82. $this->setError($validate->errors()->first());
  83. return false;
  84. }
  85. return true;
  86. }
  87. /**
  88. * 淘宝商品转链参数校验
  89. * @param $data
  90. */
  91. public function transferGoods($data)
  92. {
  93. $validate = Validator::make($data,
  94. [
  95. "user_id"=>"required",
  96. "goods_id"=>"required",
  97. ]
  98. );
  99. if($validate->fails()){
  100. //验证错误
  101. $this->setError($validate->errors()->first());
  102. return false;
  103. }
  104. return true;
  105. }
  106. }