<?php

namespace App\Http\Controllers\api;

use App\Models\Config;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\api\Issue;
use App\Http\Controllers\api\NewPc;

/**
 * pc28，根据配置的游戏玩法返回指定的数据
 */
class PcIssue extends BaseController
{

    /**
     * @api {get} /pcissue/yuanTou 源头
     *
     */
    function yuanTou()
    {
        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
        if ($pc28Switch == 1) {
            //pc28分分彩/极速28
            $issueController = new NewPc();
        } else {
            //pc28
            $issueController = new Issue();
        }
        return $issueController->yuanTou();
    }


    /**
     * @api {get} /pcissue/history 天机
     *
     */
    function history()
    {
        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
        if ($pc28Switch == 1) {
            //pc28分分彩/极速28
            $issueController = new NewPc();
        } else {
            //pc28
            $issueController = new Issue();
        }  
        return $issueController->history();
    }

    /**
     * @api {get} /pcissue/prediction 预测
     */
    function prediction()
    {
        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
        if ($pc28Switch == 1) {
            //pc28分分彩/极速28
            $issueController = new NewPc();
        } else {
            //pc28
            $issueController = new Issue();
        }
        return $issueController->prediction();
    }

    /**
     * @api {get} /pcissue/countdown 倒计时
     *
     */
    public function countdown(): JsonResponse
    {
        //0:pc28 1:急速28
        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
        if ($pc28Switch == 1) {
            $issueController = new NewPc();
        } else {
            //pc28
            $issueController = new Issue();
        }
        return $issueController->countdown();
    }


    /**
     * @api {get} /pcissue 结果，走势
     */
    public function index()
    {
        //0:pc28 1:急速28
        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
        if ($pc28Switch == 1) {
            $issueController = new NewPc();
        } else {
            //pc28
            $issueController = new Issue();
        }
        return $issueController->index();
    }

    /**
     * @api {get} /pcissue/cao 统计，历史
     */
    public function cao()
    {
        $pc28Switch = Config::where('field', 'pc28_switch')->first()->val;
        if ($pc28Switch == 1) {
            //pc28分分彩/极速28
            $issueController = new NewPc();
        } else {
            //pc28
            $issueController = new Issue();
        }
        return $issueController->cao();
    }

}