Dulshan DevOps
Dulshan DevOps

Reputation: 20

Use the Amadeus API to get airline logos dynamically?

I am using the Amadeus API to build a flight booking app using backend Laravel. I have fetched the airline code from the API.

foreach ($response['data'] as $flightOffer) {
            $airline = $flightOffer['carrierCode'];
            
            $flightList[] = [
                'airline' => $airline.
                 ...
            ];
        }

Then, after I pass this data to the frontend using this array. But API does not provide airline logos.

How can I add the airline logo to this array and render it in the frontend?

Upvotes: -1

Views: 539

Answers (2)

Thoai Ngo Van
Thoai Ngo Van

Reputation: 1

Amadeus API has no logos for flights.

Upvotes: 0

Urvin Sanghavi
Urvin Sanghavi

Reputation: 42

Try this

Dynamically fetch airline logos for your flight booking app, you can use various methods. One common approach is to maintain a mapping between airline codes and their respective logos in your application.

$airlineLogos = [
    'AA' => 'american_airlines.png',
    'DL' => 'delta_airlines.png',
    // Add more entries for other airlines
];

Store the airline logos in a directory within your Laravel application (e.g., public/images/airline_logos/).

foreach ($response['data'] as $flightOffer) {
    $airline = $flightOffer['carrierCode'];

    // Get the corresponding logo filename from the mapping
    $logoFilename = $airlineLogos[$airline] ?? 'default_logo.png';

    $flightList[] = [
        'airline' => $airline,
        'logo' => asset('images/airline_logos/' . $logoFilename),
        // ... other details
    ];
}
<img src="{{ $flight['logo'] }}" alt="{{ $flight['airline'] }} Logo">

Upvotes: -1

Related Questions