<?php

namespace App\Http\Controllers\App;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Core\Auth;
use App\Services\Home\FeedService;
use App\Services\Vendor\GeTui\ApiService;
use Illuminate\Http\Request;

class VersionController extends Controller
{
    /**
     * 判断是否可以开启某版本
     */
    public function isVersion()
    {
        $isopen = true;
        return array(
            'code' => 200,
            'message' => 'success',
            'data' => array(
                'version' => '2.10.5',
                'isopen' => $isopen
            )
        );
    }

    // 获取官方宣传卡片
    public function getPartner()
    {
        $fs = new FeedService();
        $data = $fs->getPartner(2, 0);
        return response([
            'code' => 200,
            'message' => 'success',
            'data' => $data
        ]);
    }

    public function bindClient(Request $request)
    {
        $this->validate($request, [
            'client_id' => 'required'
        ]);
        $cid = $request->post('client_id');
        $uid = Auth::auth();
        $apiS = new ApiService();
        $apiS->bindAlias((string)$cid, (string)$uid);
        return response([
            'code' => 200,
            'message' => 'success'
        ]);
    }
}
