@if (isset($booking))

Order ID: {{ $booking->offer_id ?? '-' }}

Status: {{ ucfirst($booking->booking_status) }}

Amount: {{ $booking->currency }} {{ number_format($booking->total_amount, 2) }}

Created: {{ $booking->created_at ? \Carbon\Carbon::parse($booking->created_at)->format('d/m/Y H:i') : '-' }}

@if ($booking->airline_code) {{ $booking->airline_code }}

{{ $booking->airline_name }}

@endif
@php $offer = json_decode($booking->flight_info, true); @endphp
@if (isset($offer) && $offer != null)
Flight Summary
{{ $offer['slices'][0]['origin']['city_name'] ?? '' }} ({{ $offer['slices'][0]['origin']['iata_code'] ?? '' }}) {{ $offer['slices'][0]['destination']['city_name'] ?? '' }} ({{ $offer['slices'][0]['destination']['iata_code'] ?? '' }})
{{ \Carbon\Carbon::parse($offer['slices'][0]['segments'][0]['departing_at'])->format('D, d M') }} - {{ \Carbon\Carbon::parse($offer['slices'][count($offer['slices']) - 1]['segments'][0]['arriving_at'])->format( 'D, d M Y', ) }} - {{ count($offer['passengers'] ?? []) }} passenger(s)
@foreach($offer['slices'] as $index => $slice)
{{ $index === 0 ? 'Outbound Flight' : 'Return Flight' }}
@foreach($slice['segments'] as $segment)

{{ \Carbon\Carbon::parse($segment['departing_at'])->format('H:i') }} - {{ \Carbon\Carbon::parse($segment['arriving_at'])->format('H:i') }} ({{ $segment['duration'] ?? 'N/A' }})

{{ $segment['operating_carrier']['name'] ?? '' }} - {{ $segment['operating_carrier']['flight_number'] ?? '' }} @if (isset($segment['aircraft']['name']))
Aircraft: {{ $segment['aircraft']['name'] }} ({{ $segment['aircraft']['iata_code'] ?? '' }}) @endif

Flight Number: {{ $segment['operating_carrier_flight_number'] ?? '-' }}

{{ $segment['origin']['name'] ?? '' }} @if (isset($segment['origin_terminal']))
Terminal: {{ $segment['origin_terminal'] }} @endif
{{ $segment['destination']['name'] ?? '' }} @if (isset($segment['destination_terminal']))
Terminal: {{ $segment['destination_terminal'] }} @endif
@if (isset($segment['passengers'][0]))

Cabin: {{ $segment['passengers'][0]['cabin_class_marketing_name'] ?? ($booking->cabin_class ?? 'N/A') }}

@if (isset($segment['passengers'][0]['baggages']) && is_array($segment['passengers'][0]['baggages']))

@foreach ($segment['passengers'][0]['baggages'] as $baggage) {{ ucfirst($baggage['type']) }} bag: {{ $baggage['quantity'] ?? 1 }} @if (!$loop->last) , @endif @endforeach

@endif @endif
@if (!$loop->last)
@endif @endforeach

Flight type: {{ count($slice['segments']) === 1 ? 'Non-stop' : 'With stops' }}

@endforeach
Passenger Details
@foreach($passengerDetails as $passenger)

Name:
{{ $passenger['title'] ?? '' }} {{ $passenger['given_name'] ?? '' }} {{ $passenger['family_name'] ?? '' }}

Date of Birth:
{{ $passenger['born_on'] ?? '' }}

Gender:
{{ $passenger['gender'] ?? '' }}

Type:
{{ isset($passenger['type']) ? ucfirst($passenger['type']) : 'Adult' }}

Email:
{{ $passenger['email'] ?? '' }}

Phone:
{{ $passenger['phone_number'] ?? '' }}

@endforeach
@else
Flight details not available.
@endif
@else
Booking not found.
@endif