PHP code example of f1uder / livewire-throttling
1. Go to this page and download the library: Download f1uder/livewire-throttling library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
f1uder / livewire-throttling example snippets
namespace App\Http\Livewire\Test;
use Livewire\Component;
use Nrox\LivewireThrottling\ThrottlingTrait;
class TestComponent extends Component
{
use ThrottlingTrait; // use Trait
/**
* Thrown out ValidationException
* name: throttle
*/
public function test()
{
$this->rateLimit('10'); // Limit 10 requests per minute
}
public function testCallback()
{
$this->rateLimit('10', function ($sec) {
abort(429);
});
}
}
$this->clearRateLimit();
"Too many requests, try again in :sec seconds.": "Слишком много запросов, повторите попытку через :sec сек."