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