From 548e838e816ad123187ee859b6e642adfa887809 Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 4 Apr 2026 18:21:01 +1000 Subject: [PATCH] Added timezones --- .../Commands/PopulateAirportTimezones.php | 37 +++++++++++++++++++ config/app.php | 1 + 2 files changed, 38 insertions(+) create mode 100644 app/Console/Commands/PopulateAirportTimezones.php diff --git a/app/Console/Commands/PopulateAirportTimezones.php b/app/Console/Commands/PopulateAirportTimezones.php new file mode 100644 index 0000000..d737cae --- /dev/null +++ b/app/Console/Commands/PopulateAirportTimezones.php @@ -0,0 +1,37 @@ +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'), + 'format' => 'json', + 'by' => 'position', + 'lat' => $airport->latitude, + 'lng' => $airport->longitude, + ]); + + if ($response->ok()) { + $airport->update(['timezone' => $response->json('zoneName')]); + } + + sleep(1); + } + }); + } +} diff --git a/config/app.php b/config/app.php index 1077f9d..792f3cb 100644 --- a/config/app.php +++ b/config/app.php @@ -56,6 +56,7 @@ return [ 'domain' => env('APP_DOMAIN', 'flightsgoneby.com'), 'api_domain' => env('API_DOMAIN', 'api.flightsgoneby.com'), 'logo_api_url' => env('LOGO_API_URL', 'https://api.flightsgoneby.com'), + 'timezone_api_key' => env('TIMEZONE_API_KEY', '1234567890'), /* |-------------------------------------------------------------------------- | Application Timezone