diff --git a/src/Drivers/Cloudflare.php b/src/Drivers/Cloudflare.php index e23902d..9c55940 100644 --- a/src/Drivers/Cloudflare.php +++ b/src/Drivers/Cloudflare.php @@ -28,6 +28,10 @@ protected function process(Request $request): Fluent|false 'cityName' => $request->getHeader('cf-ipcity'), 'longitude' => $request->getHeader('cf-iplongitude'), 'latitude' => $request->getHeader('cf-iplatitude'), + 'region' => $request->getHeader('cf-region'), + 'regionCode' => $request->getHeader('cf-region-code'), + 'postalCode' => $request->getHeader('cf-postal-code'), + 'timezone' => $request->getHeader('cf-timezone'), ]); } @@ -41,6 +45,10 @@ protected function hydrate(Position $position, Fluent $location): Position $position->cityName = $location->cityName; $position->longitude = $location->longitude; $position->latitude = $location->latitude; + $position->regionName = $location->region; + $position->regionCode = $location->regionCode; + $position->postalCode = $location->postalCode; + $position->timezone = $location->timezone; return $position; } diff --git a/tests/CloudflareTest.php b/tests/CloudflareTest.php index 96de17e..19edfaf 100644 --- a/tests/CloudflareTest.php +++ b/tests/CloudflareTest.php @@ -18,6 +18,10 @@ 'CF-IPCity' => 'Boxford', 'CF-IPLatitude' => '51.75', 'CF-IPLongitude' => '-1.25', + 'CF-Region' => 'Plymouth', + 'CF-Region-Code' => 'PLY', + 'CF-Postal-Code' => 'PL5', + 'CF-Timezone' => 'Europe/London', ]); $position = Location::get('2.125.160.216'); @@ -28,17 +32,17 @@ 'ip' => '2.125.160.216', 'countryName' => null, 'countryCode' => 'GB', - 'regionCode' => null, - 'regionName' => null, + 'regionCode' => 'PLY', + 'regionName' => 'Plymouth', 'cityName' => 'Boxford', 'zipCode' => null, 'isoCode' => 'GB', - 'postalCode' => null, + 'postalCode' => 'PL5', 'latitude' => '51.75', 'longitude' => '-1.25', 'metroCode' => null, 'areaCode' => null, - 'timezone' => null, + 'timezone' => 'Europe/London', 'driver' => Cloudflare::class, ]); });