1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?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;
- }
- }
|