<?php

namespace App\Dao\Channel;

use App\Models\Channel\Channel;

class ChannelDao
{
    /**
     * 获取站点信息
     *
     * @param $channelId
     * @return array
     */
    public function getChannelById($channelId): array
    {
        if (empty($channelId)) {
            return [];
        }

        $result = Channel::where('id', $channelId)->first();
        return $result ? $result->toArray() : [];
    }

    /**
     * @param $channelUserId
     * @return array
     */
    public function getUserChannels($channelUserId): array
    {
        if (empty($channelUserId)) {
            return [];
        }

        $channels = Channel::where('channel_user_id', $channelUserId)
                           ->where('is_enabled', 1)
                           ->get();
        return $channels ? $channels->toArray() : [];
    }
}