|
|
@@ -32,9 +32,18 @@ class GoodsController extends ApiController
|
|
|
->select(['id as category_id','name'])
|
|
|
->orderBy('sort','desc')
|
|
|
->get();
|
|
|
+ $data = [];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $goods = Goods::where('is_del',0)
|
|
|
+ ->where('status',1)
|
|
|
+ ->where('shop_id',$shop_id)
|
|
|
+ ->where('category_id',$value['category_id'])->count();
|
|
|
+ if ($goods > 0){
|
|
|
+ $data[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- return $this->apiResponseSuccess('成功',$list);
|
|
|
+ return $this->apiResponseSuccess('成功',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -53,6 +62,7 @@ class GoodsController extends ApiController
|
|
|
->select(['id as type','name'])
|
|
|
->orderBy('sort','desc')
|
|
|
->get();
|
|
|
+ $data = [];
|
|
|
foreach ($category as $value){
|
|
|
$list = Goods::where('is_del',0)
|
|
|
->where('status',1)
|
|
|
@@ -65,9 +75,12 @@ class GoodsController extends ApiController
|
|
|
$goods->{'num'} = 0;//前端需要
|
|
|
}
|
|
|
$value->{'list'} = $list;
|
|
|
+ if (count($list) > 0){
|
|
|
+ $data[] = $value;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return $this->apiResponseSuccess('成功',$category);
|
|
|
+ return $this->apiResponseSuccess('成功',$data);
|
|
|
}
|
|
|
|
|
|
/**
|