Which IP are you testing with?
For localhost IP (127.0.0.1) it will always return false. So to test locally you might want add an if and return a default value
I created a new laravel app and added this package:
laravel new laracasts
cd laracasts
composer require stevebauman/location
php artisan serve
Then on the ./routes/web.php routes file I added these routes:
<?php
use Illuminate\Support\Facades\Route;
use Stevebauman\Location\Facades\Location; // <<<< Using the Façade here
Route::get('/google', function () {
// Google Public DNS
return Location::get('8.8.4.4');
});
Route::get('/local', function () {
// Localhost
dd(Location::get('127.0.0.1'));
});
Route::get('/request', function () {
// IP from request
// will be false locally, as it is
// the same as 127.0.0.1
dd(Location::get(request()->getClientIp()));
});
Navigating to http://127.0.0.1:8000/google , which have Google's Public DNS server IP hard-coded I get:
{
"ip": "8.8.4.4",
"countryName": "United States",
"countryCode": "US",
"regionCode": "VA",
"regionName": "Virginia",
"cityName": "Ashburn",
"zipCode": "20149",
"isoCode": null,
"postalCode": null,
"latitude": "39.03",
"longitude": "-77.5",
"metroCode": null,
"areaCode": "VA",
"driver": "Stevebauman\Location\Drivers\IpApi"
}
Navigating to http://127.0.0.1:8000/local , I get:
false
And Navigating to http://127.0.0.1:8000/request , from my machine I also get
false
The reason is when I request from my local machine to a local server my IP is 127.0.0.1.
This might be your issue. To test locally you might want to add if block to test if the result is false, and the client IP is 127.0.0.1 then you'd use a default value.