Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.11k stars 372 forks source link

Json encoding of Torann\GeoIP\Location #65

Closed nikolaynesov closed 5 years ago

nikolaynesov commented 8 years ago

Json encoding of Torann\GeoIP\Location returns empty string. Expected: json encoded attributes.

nikolaynesov commented 8 years ago

quick and dirty workaround would be json_encode(array_values((array)geoip()->getLocation())[0])

allan-empalmado commented 7 years ago

If using Laravel this also works Response::json(geoip()->getLocation()->toArray());

rehanshaikh1823 commented 11 months ago

I am using Laravel.

$location = GeoIP::getLocation(); $locationArray = $location->toArray(); $jsonData = json_encode($locationArray); dd($jsonData);