From dfa7f0f8da5a8f57a9d56b3502e6b73d46929040 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 15:30:28 +0800 Subject: [PATCH] =?UTF-8?q?$channel=5Fids=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 836b29b..844d7bb 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -37,12 +37,10 @@ class IndexController extends Controller # 我的频道 if ($this->user_id) { - $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels'); - if ($channel_ids) { - $my_channels = Channel::where('agent_id', $this->agent_id) - ->whereIn('id', $channel_ids) - ->get(['id', 'name', 'icon']); - } + $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels') ?? []; + $my_channels = Channel::where('agent_id', $this->agent_id) + ->whereIn('id', $channel_ids) + ->get(['id', 'name', 'icon']); } else { $my_channels = Channel::where('agent_id', $this->agent_id) ->where('pid', '<>', 0)