Skip to content

Instantly share code, notes, and snippets.

@DarkGhostHunter
Last active June 2, 2020 04:15
Show Gist options
  • Save DarkGhostHunter/1bacb79cfe86141aee10f337bb5f9ab8 to your computer and use it in GitHub Desktop.
Save DarkGhostHunter/1bacb79cfe86141aee10f337bb5f9ab8 to your computer and use it in GitHub Desktop.
Simple Trait to throttle method calls.
<?php
namespace App\Throttler;
trait ThrottlesCalls
{
/**
* Throttles the next method call.
*
* @param int $tries
* @param int $minutes
* @return \App\Throttler
*/
public function throttle($tries, $minutes)
{
return app(Throttler::class)->setTarget($this)->throttle($tries, $minutes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment