From 8949ddc5f42a07d757df06f65e932c2510567b59 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 24 Aug 2021 15:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E6=B0=94=E7=88=86=E6=AC=BE=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E9=94=80=E9=87=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 6e162d7..20b740c 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -82,10 +82,10 @@ class IndexController extends Controller } # 人气爆款 - $hots = AgentProduct::query() + $hots = AgentProduct::with('product:id,title,pictures') //必须查询ID才能正常查询 ->where('agent_id', $this->agent_id) ->select('id', 'sale', 'product_id', 'price', 'original_price') //必须查询product_id才能with - ->with('product:id,title,pictures') //必须查询ID才能正常查询 + ->orderBy('sale', 'desc')->orderBy('id', 'desc') ->limit(6)->get(); if (!$hots->isEmpty()) { foreach ($hots as &$v) {