超管后台品牌列表

main
limu 12 months ago
parent 11802839fc
commit b631520f57
  1. 1
      app/common/repositories/store/StoreCategoryRepository.php
  2. 25
      app/controller/admin/store/StoreBrand.php
  3. 3
      route/admin/product.php

@ -107,6 +107,7 @@ class StoreCategoryRepository extends BaseRepository
*/
public function getBrandList()
{
return app()->make(StoreBrandRepository::class)->getAll();
}

@ -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);
}
}

@ -150,6 +150,9 @@ Route::group(function () {
Route::get('lst', '/lst')->name('systemStoreBrandLst')->option([
'_alias' => '列表',
]);
Route::get('brandList', '/all')->name('systemStoreBrandAll')->option([
'_alias' => '列表',
]);
Route::post('status/:id', '/switchStatus')->name('systemStoreBrandSwithStatus')->option([
'_alias' => '修改状态',
]);

Loading…
Cancel
Save