We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 948617d commit de95ca2Copy full SHA for de95ca2
src/Services/IPData.php
@@ -3,6 +3,7 @@
3
namespace Torann\GeoIP\Services;
4
5
use Exception;
6
+use Illuminate\Support\Arr;
7
use Torann\GeoIP\Support\HttpClient;
8
9
/**
@@ -47,6 +48,21 @@ public function locate($ip)
47
48
throw new Exception('Request failed (' . $this->client->getErrors() . ')');
49
}
50
- return $this->hydrate(json_decode($data[0], true));
51
+ $json = json_decode($data[0], true);
52
+
53
+ return $this->hydrate([
54
+ 'ip' => $ip,
55
+ 'iso_code' => $json['country_code'],
56
+ 'country' => $json['continent_name'],
57
+ 'city' => $json['city'],
58
+ 'state' => $json['region_code'],
59
+ 'state_name' => $json['region'],
60
+ 'postal_code' => $json['postal'],
61
+ 'lat' => $json['latitude'],
62
+ 'lon' => $json['longitude'],
63
+ 'timezone' => Arr::get($json, 'time_zone.name'),
64
+ 'continent' => Arr::get($json, 'continent_code'),
65
+ 'currency' => Arr::get($json, 'currency.code'),
66
+ ]);
67
68
0 commit comments