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)