简体   繁体   English

如何使用ip地址“request() - > ip();”获取货币区域设置

[英]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? 我正在使用laravel,我需要最好的包来从IP地址获得编队,我使用laravel geo和laravel geoip但每次都返回null,请你提出建议吗?

geoip : geoip:

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

geo : 地理:

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

Laravel Geoip should be a good option for you. Laravel Geoip应该是一个不错的选择。 Check the github repo from here 从这里检查github repo

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'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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