How to check city with ip address

450 views Asked by At

I am working on a real estate site. I need to show properties of a specific city only on the home page. How can I check the ip of the visitor and check the city from where he is visiting ?

3

There are 3 answers

0
Abolfazl Mohajeri On

You can get user ip with:

$request->ip()

Then you need to send request to api that give you a location of an ip, some of these services are:

  1. https://ip-api.com
  2. https://ipstack.com
  3. https://ipapi.co
0
Vidhi Patel On

you can use : request()->ip();

or

you can also use \Request::ip();

0
Kumar On

Thanks everybody. Will try these options.