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) {