|
|
|
@ -40,8 +40,8 @@ class StoreBrand extends BaseController |
|
|
|
|
*/ |
|
|
|
|
public function lst() |
|
|
|
|
{ |
|
|
|
|
[$page , $limit] = $this->getPage(); |
|
|
|
|
$where = $this->request->params(['brand_category_id','brand_name']); |
|
|
|
|
[$page, $limit] = $this->getPage(); |
|
|
|
|
$where = $this->request->params(['brand_category_id', 'brand_name']); |
|
|
|
|
|
|
|
|
|
return app('json')->success($this->repository->getList($where, $page, $limit)); |
|
|
|
|
} |
|
|
|
@ -57,23 +57,23 @@ class StoreBrand extends BaseController |
|
|
|
|
return app('json')->success('添加成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function update($id,validate $validate) |
|
|
|
|
public function update($id, validate $validate) |
|
|
|
|
{ |
|
|
|
|
$data = $this->checkParams($validate); |
|
|
|
|
if(!$this->repository->meExists($id)) |
|
|
|
|
if (!$this->repository->meExists($id)) |
|
|
|
|
return app('json')->fail('数据不存在'); |
|
|
|
|
if (!$this->repository->parentExists($data['brand_category_id'])) |
|
|
|
|
return app('json')->fail('上级分类不存在'); |
|
|
|
|
$this->repository->update($id,$data); |
|
|
|
|
$this->repository->update($id, $data); |
|
|
|
|
return app('json')->success('编辑成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function delete($id) |
|
|
|
|
{ |
|
|
|
|
if(!$this->repository->meExists($id)) |
|
|
|
|
if (!$this->repository->meExists($id)) |
|
|
|
|
return app('json')->fail('数据不存在'); |
|
|
|
|
if($this->repository->getBrandHasProduct($id)) |
|
|
|
|
if ($this->repository->getBrandHasProduct($id)) |
|
|
|
|
return app('json')->fail('该品牌下存在商品'); |
|
|
|
|
$this->repository->delete($id); |
|
|
|
|
return app('json')->success('删除成功'); |
|
|
|
@ -85,16 +85,17 @@ class StoreBrand extends BaseController |
|
|
|
|
return app('json')->fail('数据不存在'); |
|
|
|
|
return app('json')->success($this->repository->get($id)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 验证 |
|
|
|
|
* @param validate $validate |
|
|
|
|
* @param validate $validate |
|
|
|
|
* @param bool $isCreate |
|
|
|
|
* @return array |
|
|
|
|
* @author Qinii |
|
|
|
|
*/ |
|
|
|
|
public function checkParams(validate $validate) |
|
|
|
|
{ |
|
|
|
|
$data = $this->request->params(['brand_category_id','brand_name','is_show','sort','pic']); |
|
|
|
|
$data = $this->request->params(['brand_category_id', 'brand_name', 'is_show', 'sort', 'pic']); |
|
|
|
|
$validate->check($data); |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
@ -137,4 +138,10 @@ class StoreBrand extends BaseController |
|
|
|
|
$this->repository->update($id, ['is_show' => $status]); |
|
|
|
|
return app('json')->success('修改成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function all() |
|
|
|
|
{ |
|
|
|
|
$data = $this->repository->getAll(); |
|
|
|
|
return app('json')->success($data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|