This commit is contained in:
2025-10-22 20:08:22 +05:00
commit 736e3bef18
2573 changed files with 120385 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Modules\IpStack\Repositories;
use Stevebauman\Location\Facades\Location;
class IpStackRepository
{
/**
* Get ip stack
*/
public static function isLocalIp(string $ip): bool
{
return ! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
}
/**
* Get country code from ip
*/
public static function getCountryCodeFromIp(?string $ip): string
{
if (is_null($ip)) {
return 'TM';
}
return self::isLocalIp($ip) ? 'TM' : Location::get($ip)->countryCode ?? 'TM';
}
}