public function sendCode(Request $request) { $phone = $request->get('phone'); if(empty($phone)){ return ['code'=>10001, 'msg' => '手机号不能为空', 'data'=> []]; } $cache = Cache::get($phone.date("Y:m:d")); if($cache > 5){ return ['code' => 10003, 'msg' => '每天只能发送五条短信', 'data' => []]; } $captcha = (new Phone())->sendSms($phone); Cache::put($phone,$captcha,60*15); $num = $cache + 1; Cache::put($phone.date("Y:m:d"),$num,60*60*24); return ['code' => 200, 'msg' => '短信发送成功', 'data' => $captcha]; }