/**
* Increment the counter for a given key for a given decay time.
*
* @param string $key
* @param float|int $decayMinutes
* @return int
*/publicfunctionhit($key,$decayMinutes=1){$this->cache->add($key.':timer',$this->availableAt($decayMinutes*60),$decayMinutes);$added=$this->cache->add($key,0,$decayMinutes);$hits=(int)$this->cache->increment($key);if(!$added&&$hits==1){$this->cache->put($key,1,$decayMinutes);}return$hits;}
tooManyAttempts
/**
* Determine if the given key has been "accessed" too many times.
*
* @param string $key
* @param int $maxAttempts
* @param float|int $decayMinutes
* @return bool
*/publicfunctiontooManyAttempts($key,$maxAttempts,$decayMinutes=1){if($this->attempts($key)>=$maxAttempts){if($this->cache->has($key.':timer')){returntrue;}$this->resetAttempts($key);}returnfalse;}/**
* Get the number of attempts for the given key.
*
* @param string $key
* @return mixed
*/publicfunctionattempts($key){return$this->cache->get($key,0);}/**
* Reset the number of attempts for the given key.
*
* @param string $key
* @return mixed
*/publicfunctionresetAttempts($key){return$this->cache->forget($key);}
resolveMaxAttempts
/**
* Resolve the number of attempts if the user is authenticated or not.
*
* @param \Illuminate\Http\Request $request
* @param int|string $maxAttempts
* @return int
*/protectedfunctionresolveMaxAttempts($request,$maxAttempts){if(Str::contains($maxAttempts,'|')){$maxAttempts=explode('|',$maxAttempts,2)[$request->user()?1:0];}return(int)$maxAttempts;}