UserControllerValidate.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace App\Http\Validate\User;
  3. use App\Http\Validate\BaseValidate;
  4. use Illuminate\Support\Facades\Validator;
  5. class UserControllerValidate extends BaseValidate
  6. {
  7. /**
  8. * 粉丝列表参数校验
  9. * @param $data
  10. */
  11. public function getFansList($data)
  12. {
  13. $validate = Validator::make($data,
  14. [
  15. "page"=>"required|integer",
  16. "page_size"=>"required|integer",
  17. "type"=>"required:in:1,2"
  18. ]
  19. );
  20. if($validate->fails()){
  21. //验证错误
  22. $this->setError($validate->errors()->first());
  23. return false;
  24. }
  25. return true;
  26. }
  27. /**
  28. * 收汁明细参数校验
  29. * @param $data
  30. */
  31. public function getFinanceList($data)
  32. {
  33. $validate = Validator::make($data,
  34. [
  35. "page"=>"required|integer",
  36. "page_size"=>"required|integer",
  37. "finance_type"=>"required|in:0,1,2"
  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 getFinanceDetail($data)
  52. {
  53. $validate = Validator::make($data,
  54. [
  55. "id"=>"required|integer",
  56. ]
  57. );
  58. if($validate->fails()){
  59. //验证错误
  60. $this->setError($validate->errors()->first());
  61. return false;
  62. }
  63. return true;
  64. }
  65. /**
  66. * 提现参数校验
  67. * @param $data
  68. */
  69. public function getCash($data)
  70. {
  71. $validate = Validator::make($data,
  72. [
  73. "amount"=>"required|integer",
  74. ]
  75. );
  76. if($validate->fails()){
  77. //验证错误
  78. $this->setError($validate->errors()->first());
  79. return false;
  80. }
  81. if($data["amount"] < 100){
  82. $this->setError("提现金额不能小于1元");
  83. return false;
  84. }
  85. return true;
  86. }
  87. /**
  88. * 获取推广二维码参数校验
  89. * @param $data
  90. */
  91. public function getRecommendUrl($data)
  92. {
  93. $validate = Validator::make($data,
  94. [
  95. "code"=>"required",
  96. ]
  97. );
  98. if($validate->fails()){
  99. //验证错误
  100. $this->setError($validate->errors()->first());
  101. return false;
  102. }
  103. return true;
  104. }
  105. /**
  106. * 反馈参数校验接口
  107. * @param $data
  108. */
  109. public function feedback($data)
  110. {
  111. $validate = Validator::make($data,
  112. [
  113. "content"=>"required",
  114. ]
  115. );
  116. if($validate->fails()){
  117. //验证错误
  118. $this->setError($validate->errors()->first());
  119. return false;
  120. }
  121. return true;
  122. }
  123. }