OrderControllerValidate.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Http\Validate\Order;
  3. use App\Http\Validate\BaseValidate;
  4. use Illuminate\Support\Facades\Validator;
  5. class OrderControllerValidate extends BaseValidate
  6. {
  7. /**
  8. * 订单列表参数校验
  9. * @param $data
  10. */
  11. public function getOrderList($data)
  12. {
  13. $validate = Validator::make($data,
  14. [
  15. "page"=>"required|integer",
  16. "page_size"=>"required|integer",
  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. * @return bool
  30. */
  31. public function getOrderDetail($data)
  32. {
  33. $validate = Validator::make($data,
  34. [
  35. "order_id"=>"required|integer",
  36. ]
  37. );
  38. if($validate->fails()){
  39. //验证错误
  40. $this->setError($validate->errors()->first());
  41. return false;
  42. }
  43. return true;
  44. }
  45. }