isSubmitlimitation($cacheKey)) return [false,'已发送验证码,请勿重复操作!']; $code = $this->createCode(); //如果发送成功 if($this->sendCode()){ Cache::add($cacheKey,$code,1); return [true,'']; }else{ return [false,'意外错误!']; } } public function createCode(){ return "123123"; } public function sendCode(){ return true; } public function isSubmitlimitation($cacheKey){ if(Cache::has($cacheKey)){ return false; } return true; } }