"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; } }