From cdf6a2fe238274fb6d12803d260bb60f29624f0b Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 27 Jul 2021 18:41:37 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=A6=96=E9=A1=B5=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E5=9B=BE=E6=94=B9=E6=88=90=E4=B8=93=E9=A2=98=EF=BC=9B2?= =?UTF-8?q?=E3=80=81=E5=85=B3=E8=81=94=E6=9F=A5=E8=AF=A2=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BB=A3=E7=A0=81=E7=AE=80=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 69cf657..f97f3df 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; -use App\Models\Advertising; use App\Models\Channel; use App\Models\Notice; use App\Models\AgentProduct; use App\Models\Slide; +use App\Models\Special; use App\Models\UserChannel; /** @@ -28,23 +28,26 @@ class IndexController extends Controller # 我的频道 $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels'); - $my_channels = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']); + $my_channels = Channel::whereIn('id', $channel_ids)->get(['id', 'name', 'icon']); - # 广告图 - $home_ad1 = Advertising::where('agent_id', $this->agent_id)->value('picture'); + # 专题列表 + $special = Special::query() + ->where('agent_id', $this->agent_id) + ->orderBy('sort') + ->orderBy('id') + ->get(['id', 'picture_ad']); # 人气爆款 -// $hots = AgentProduct::select(['title', 'price', 'original_price', 'pictures'])->get(); $hots = AgentProduct::query() ->select('id', 'sale', 'product_id', 'price', 'original_price') //必须查询product_id才能with - ->with(['product' => fn ($query) => $query->select('id', 'title', 'pictures')]) //必须查询ID才能正常查询 + ->with('product:id,title,pictures') //必须查询ID才能正常查询 ->limit(6)->get(); return $this->success([ 'slide' => $slide, 'notice' => $notice, 'my_channels' => $my_channels, - 'home_ad1' => $home_ad1, + 'special' => $special, 'hots' => $hots, ]); }