优化上架商品查询
parent
f60e8be3cc
commit
68edb62b37
|
|
@ -16,7 +16,6 @@ class HotController extends Controller
|
||||||
public function __invoke()
|
public function __invoke()
|
||||||
{
|
{
|
||||||
$skus = ProductSku::online()
|
$skus = ProductSku::online()
|
||||||
->whereRelation('category', 'is_show', true)
|
|
||||||
->latest('sales')
|
->latest('sales')
|
||||||
->limit(20)
|
->limit(20)
|
||||||
->get();
|
->get();
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,6 @@ class ProductSkuController extends Controller
|
||||||
return ProductSku::select(['id', 'name', 'cover', 'sell_price', 'vip_price', 'sales'])
|
return ProductSku::select(['id', 'name', 'cover', 'sell_price', 'vip_price', 'sales'])
|
||||||
->filter($input)
|
->filter($input)
|
||||||
->online()
|
->online()
|
||||||
->whereRelation('category', 'is_show', true)
|
|
||||||
->simplePaginate(PaginatorHelper::resolvePerPage('per_page', 20, 50));
|
->simplePaginate(PaginatorHelper::resolvePerPage('per_page', 20, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,7 +186,7 @@ class ProductSkuController extends Controller
|
||||||
|
|
||||||
$paginator = ProductPartSku::with('sku:id,name,cover,sell_price,vip_price,sales')
|
$paginator = ProductPartSku::with('sku:id,name,cover,sell_price,vip_price,sales')
|
||||||
->whereHas('sku', function ($query) {
|
->whereHas('sku', function ($query) {
|
||||||
$query->online()->whereRelation('category', 'is_show', true);
|
return $query->online();
|
||||||
})
|
})
|
||||||
->where('part_id', $productPart->id)
|
->where('part_id', $productPart->id)
|
||||||
->latest('sort')
|
->latest('sort')
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class ProductSku extends Model
|
||||||
*/
|
*/
|
||||||
public function scopeOnline($query)
|
public function scopeOnline($query)
|
||||||
{
|
{
|
||||||
return $query->whereNotNull('release_at');
|
return $query->whereNotNull('release_at')->whereRelation('category', 'is_show', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue