From 30d5feaf635d66d90d491aa04fdc71f99c3893d5 Mon Sep 17 00:00:00 2001 From: josh Date: Fri, 3 Jul 2026 12:08:32 +1000 Subject: [PATCH] Updated scheduled tasks --- app/DTOs/FlightStatData.php | 15 +++++++++++++++ app/Http/Controllers/FlightController.php | 3 +++ resources/js/Pages/AddFlight.vue | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/DTOs/FlightStatData.php b/app/DTOs/FlightStatData.php index 4435a52..96dd118 100644 --- a/app/DTOs/FlightStatData.php +++ b/app/DTOs/FlightStatData.php @@ -10,6 +10,8 @@ readonly class FlightStatData public ?string $aircraft_registration, public ?Carbon $estimated_departure_utc, public ?Carbon $estimated_arrival_utc, + public ?Carbon $scheduled_departure_local, + public ?Carbon $scheduled_arrival_local, public ?string $equipment_iata, public ?string $departure_iata, public ?string $arrival_iata, @@ -29,6 +31,17 @@ readonly class FlightStatData ...$codeshares, ]))); + $departureTimezone = $flightData['departureAirport']['timeZoneRegionName'] ?? null; + $arrivalTimezone = $flightData['arrivalAirport']['timeZoneRegionName'] ?? null; + + $scheduledDepartureLocal = isset($flightData['schedule']['scheduledDeparture'], $departureTimezone) + ? Carbon::parse($flightData['schedule']['scheduledDeparture'], $departureTimezone) + : null; + + $scheduledArrivalLocal = isset($flightData['schedule']['scheduledArrival'], $arrivalTimezone) + ? Carbon::parse($flightData['schedule']['scheduledArrival'], $arrivalTimezone) + : null; + return new self( aircraft_registration: $flightData['positional']['flexTrack']['tailNumber'] ?? null, estimated_departure_utc: isset($flightData['schedule']['estimatedActualDepartureUTC']) @@ -37,6 +50,8 @@ readonly class FlightStatData estimated_arrival_utc: isset($flightData['schedule']['estimatedActualArrivalUTC']) ? Carbon::parse($flightData['schedule']['estimatedActualArrivalUTC']) : null, + scheduled_departure_local: $scheduledDepartureLocal, + scheduled_arrival_local: $scheduledArrivalLocal, equipment_iata: $flightData['additionalFlightInfo']['equipment']['iata'] ?? null, departure_iata: $flightData['departureAirport']['iata'] ?? null, arrival_iata: $flightData['arrivalAirport']['iata'] ?? null, diff --git a/app/Http/Controllers/FlightController.php b/app/Http/Controllers/FlightController.php index 6bcf171..10c2455 100644 --- a/app/Http/Controllers/FlightController.php +++ b/app/Http/Controllers/FlightController.php @@ -75,6 +75,7 @@ class FlightController extends Controller $fromOptions = []; $toOptions = []; $aircraftOptions = []; + $flightData = null; if (strlen($number) >= 3 && $isIata) { $flightStatsApi = new FlightStatsService(); @@ -133,6 +134,8 @@ class FlightController extends Controller 'from_options' => $fromOptions, 'to_options' => $toOptions, 'aircraft_options' => $aircraftOptions, + 'scheduled_departure_time' => $flightData?->scheduled_departure_local?->format('H:i'), + 'scheduled_arrival_time' => $flightData?->scheduled_arrival_local?->format('H:i'), ]); } diff --git a/resources/js/Pages/AddFlight.vue b/resources/js/Pages/AddFlight.vue index 82a70cc..d913c54 100644 --- a/resources/js/Pages/AddFlight.vue +++ b/resources/js/Pages/AddFlight.vue @@ -50,6 +50,8 @@ interface LookupResult { from_options: { value: number; title: string; country_code: string }[] to_options: { value: number; title: string; country_code: string }[] aircraft_options: { value: number; title: string }[] + scheduled_departure_time: string | null + scheduled_arrival_time: string | null } const lookupResult = ref(null) @@ -196,7 +198,7 @@ watch(() => form.departure_date, (newVal) => { form.arrival_date = `${arr.getFullYear()}-${pad(arr.getMonth() + 1)}-${pad(arr.getDate())}T${pad(arr.getHours())}:${pad(arr.getMinutes())}` }) -const getArrivalBound = (form, offsetDays: number) => { +const getArrivalBound = (form: any, offsetDays: number) => { if (!form.departure_date) return undefined const pad = (n: number) => String(n).padStart(2, '0') const d = new Date(form.departure_date)