Added timezones

This commit is contained in:
2026-04-04 18:21:01 +10:00
parent baff2066e6
commit 548e838e81
2 changed files with 38 additions and 0 deletions
@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands;
use App\Models\Airport;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('app:populate-airport-timezones')]
#[Description('Command description')]
class PopulateAirportTimezones extends Command
{
/**
* Execute the console command.
*/
public function handle()
{
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'),
'format' => 'json',
'by' => 'position',
'lat' => $airport->latitude,
'lng' => $airport->longitude,
]);
if ($response->ok()) {
$airport->update(['timezone' => $response->json('zoneName')]);
}
sleep(1);
}
});
}
}
+1
View File
@@ -56,6 +56,7 @@ return [
'domain' => env('APP_DOMAIN', 'flightsgoneby.com'), 'domain' => env('APP_DOMAIN', 'flightsgoneby.com'),
'api_domain' => env('API_DOMAIN', 'api.flightsgoneby.com'), 'api_domain' => env('API_DOMAIN', 'api.flightsgoneby.com'),
'logo_api_url' => env('LOGO_API_URL', 'https://api.flightsgoneby.com'), 'logo_api_url' => env('LOGO_API_URL', 'https://api.flightsgoneby.com'),
'timezone_api_key' => env('TIMEZONE_API_KEY', '1234567890'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Timezone | Application Timezone