diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 32f1f1d..57c2c31 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -36,19 +36,15 @@ class IndexController extends Controller ->orderBy('sort')->orderBy('id', 'desc')->get(['id', 'title']); # 我的频道 + $my_channels = []; if ($this->user_id) { $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) - ->orderBy('id') - ->limit(8) - ->get(['id', 'name', 'icon']); } - if (!$my_channels->isEmpty()) { + + if ($my_channels && !$my_channels->isEmpty()) { foreach ($my_channels as &$v) { $v->icon = $img_prefix . $v->icon; }