From 30b56ece8a84022c270568c9b6fe517e39aa349c Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 4 Apr 2026 18:36:27 +1000 Subject: [PATCH] Added timezones --- app/Console/Commands/PopulateAirportTimezones.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/PopulateAirportTimezones.php b/app/Console/Commands/PopulateAirportTimezones.php index d737cae..08927f3 100644 --- a/app/Console/Commands/PopulateAirportTimezones.php +++ b/app/Console/Commands/PopulateAirportTimezones.php @@ -6,9 +6,10 @@ use App\Models\Airport; use Illuminate\Console\Attributes\Description; use Illuminate\Console\Attributes\Signature; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Http; #[Signature('app:populate-airport-timezones')] -#[Description('Command description')] +#[Description('Populate timezone data for all airports using lat/lng')] class PopulateAirportTimezones extends Command { /** @@ -18,16 +19,20 @@ class PopulateAirportTimezones extends Command { Airport::whereNull('timezone')->chunk(100, function ($airports) { foreach ($airports as $airport) { - $response = Http::get('http://api.timezonedb.com/v2.1/get-timezone', [ - 'key' => config('app.timezone_db_key'), + $response = Http::withoutVerifying() + ->withOptions(['allow_redirects' => false]) + ->get('http://api.timezonedb.com/v2.1/get-time-zone', [ + 'key' => config('app.timezone_api_key'), 'format' => 'json', 'by' => 'position', - 'lat' => $airport->latitude, - 'lng' => $airport->longitude, + 'lat' => $airport->latitude_deg, + 'lng' => $airport->longitude_deg, ]); if ($response->ok()) { $airport->update(['timezone' => $response->json('zoneName')]); + } else { + dd($response->json()); } sleep(1);