Added timezones
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user