简体   繁体   中英

how can i get currency locale using ip address “ request()->ip();”

I'm using laravel and I need the best package to get formations from IP address, I used laravel geo and laravel geoip but return null every time, please can you propose?

geoip :

$location = geoip()->getLocation(); 

geo :

$ip = request()->ip();
$countryCode = Geo::location()->ipCountry($ip);

Laravel Geoip should be a good option for you. Check the github repo from here

You can use this documentation to get started: Documentation

Looking at your code it would be something like this:

$ip = request()->ip(); 
$geoData = geoip($ip);
$country = $geoData['country'];
$currency = $geoData['currency'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM