agent_id)->where('status', 1) ->orderBy('sort')->orderBy('id', 'DESC')->limit(10)->get(['title','url']); # 公告 $notice = Notice::where('agent_id', $this->agent_id)->limit(10)->get(['title', 'updated_at']); # 我的频道 $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels'); $my_channels = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']); # 广告图 $home_ad1 = Advertising::where('agent_id', $this->agent_id)->value('picture'); # 人气爆款 // $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才能正常查询 ->limit(6)->get(); return $this->success([ 'slide' => $slide, 'notice' => $notice, 'my_channels' => $my_channels, 'home_ad1' => $home_ad1, 'hots' => $hots, ]); } }