6
0
Fork 0

优化上架商品查询

release
李静 2021-12-08 17:16:15 +08:00
parent f60e8be3cc
commit 68edb62b37
3 changed files with 2 additions and 4 deletions

View File

@ -16,7 +16,6 @@ class HotController extends Controller
public function __invoke()
{
$skus = ProductSku::online()
->whereRelation('category', 'is_show', true)
->latest('sales')
->limit(20)
->get();

View File

@ -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')

View File

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