123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace App\Http\Validate\Buy;
- use App\Http\Validate\BaseValidate;
- use Illuminate\Support\Facades\Validator;
- class BuyControllerValidate extends BaseValidate
- {
- /**
- * 电商平台分类列表参数校验
- * @param $data
- * @return bool
- */
- public function getCateList($data)
- {
- $validate = Validator::make($data,
- [
- "source"=>"required",
- ]
- );
- if($validate->fails()){
- //验证错误
- $this->setError($validate->errors()->first());
- return false;
- }
- return true;
- }
- /**
- * 商品列表参数校验
- * @param $data
- */
- public function getGoodsList($data)
- {
- $validate = Validator::make($data,
- [
- "source"=>"required",
- "cat_id"=>"required|integer",
- "page"=>"required|integer",
- "page_size"=>"required|integer",
- ]
- );
- if($validate->fails()){
- //验证错误
- $this->setError($validate->errors()->first());
- return false;
- }
- return true;
- }
- /**
- * 商品详情页参数校验
- * @param $data
- */
- public function getGoodsDetail($data)
- {
- $validate = Validator::make($data,
- [
- "source"=>"required",
- "goods_id"=>"required",
- ]
- );
- if($validate->fails()){
- //验证错误
- $this->setError($validate->errors()->first());
- return false;
- }
- return true;
- }
- /**
- * 搜索商品参数校验
- * @param $data
- */
- public function getGoodsSearch($data)
- {
- $validate = Validator::make($data,
- [
- "source"=>"required",
- "keyword"=>"required",
- "page"=>"required",
- "page_size"=>"required",
- ]
- );
- if($validate->fails()){
- //验证错误
- $this->setError($validate->errors()->first());
- return false;
- }
- return true;
- }
- /**
- * 淘宝商品转链参数校验
- * @param $data
- */
- public function transferGoods($data)
- {
- $validate = Validator::make($data,
- [
- "user_id"=>"required",
- "goods_id"=>"required",
- ]
- );
- if($validate->fails()){
- //验证错误
- $this->setError($validate->errors()->first());
- return false;
- }
- return true;
- }
- }
|