all(); if(isset($params['token'])){ $cacheKey = $params['token']; if(Cache::has($cacheKey)){ $num = Cache::get($cacheKey); if($num >= 10){ $json=[ 'code'=>300, 'errorMessages' => 'Too many request,please wait a moment', 'success' =>false, ]; }else{ $num++; Cache::add($cacheKey,$num,3); return $next($request); } return response()->json($json); }else{ Cache::add($cacheKey,1,3); } } $json=[ 'code'=>300, 'errorMessages' => 'illegal access', 'success' =>false, ]; return response()->json($json); } }