<?php

namespace app\controller;

use support\Request;
use Respect\Validation\Validator as v;

class Apply
{
    public function check(Request $request)
    {
        $email=$request->input('email',null);
        $domain=$request->input('domain',null);
        $cert=$request->input('cert',null);
        if(!$email||!$domain||!$cert){
            return json(['code'=>404,'msg'=>'缺少参数，请刷新重试']);
        }
        if(!in_array($cert,array('R3','Laysense','FWNET'))){
            return json(['code'=>404,'msg'=>'证书类型错误或不存在']);
        }
        if(in_array($cert,array('Laysense','FWNET'))){
            return json(['code'=>403,'msg'=>'当前证书类型'.$cert.'暂时无法颁发']);
        }
        if(!v::domain($innerDomain)->validate($domain))
        return view('index');
    }
}
