PHP code example of areia-lab / laravel-traffic-control
1. Go to this page and download the library: Download areia-lab/laravel-traffic-control 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/ */
areia-lab / laravel-traffic-control example snippets
namespace AreiaLab\TrafficControl\Rules;
use Illuminate\Http\Request;
class GeoBlockRule
{
public function handle(Request $request)
{
$country = $this->lookupCountry($request->ip());
if (in_array($country, ['CN', 'RU'])) {
return response('Not available in your region', 403);
}
return true;
}
protected function lookupCountry($ip)
{
return 'US';
}
}