|
@@ -100,6 +100,11 @@ class GoodsService
|
|
|
$pageSize = $request->get('pageSize');
|
|
|
$goodsName = $request->get('goods_name', '');
|
|
|
$categoryId = $request->get('join_goods_category_id', null);
|
|
|
+ if ($categoryId == null) {
|
|
|
+ $categoryId = [65, 43];
|
|
|
+ } elseif (is_string($categoryId)) {
|
|
|
+ $categoryId = [$categoryId];
|
|
|
+ }
|
|
|
|
|
|
$rows = Goods::with([
|
|
|
'category' => function ($query) {
|
|
@@ -117,10 +122,7 @@ class GoodsService
|
|
|
$q->where('goods_name', 'like', '%' . $goodsName . '%')
|
|
|
->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
});
|
|
|
- })->when($categoryId != null, function ($query) use ($categoryId) {
|
|
|
- $query->where('join_goods_category_id', $categoryId);
|
|
|
- })
|
|
|
- ->whereIn('join_goods_category_id', [65, 43])
|
|
|
+ })->whereIn('join_goods_category_id', $categoryId)
|
|
|
->orderBy('goods_addtimes', 'DESC')
|
|
|
->forPage($page, $pageSize)
|
|
|
->get()
|
|
@@ -130,9 +132,7 @@ class GoodsService
|
|
|
$q->where('goods_name', 'like', '%' . $goodsName . '%')
|
|
|
->OrWhere('goods_title', 'like', '%' . $goodsName . '%');
|
|
|
});
|
|
|
- })->when($categoryId != null, function ($query) use ($categoryId) {
|
|
|
- $query->where('join_goods_category_id', $categoryId);
|
|
|
- })->whereIn('join_goods_category_id', [65, 43])->count();
|
|
|
+ })->whereIn('join_goods_category_id', $categoryId)->count();
|
|
|
|
|
|
foreach ($rows as &$row) {
|
|
|
$row['goods_cover'] = getenv('STORAGE_DOMAIN') . $row['goods_cover'];
|