diff --git a/app/Http/Controllers/Api/LogoController.php b/app/Http/Controllers/Api/LogoController.php index 134e662..0c4518a 100644 --- a/app/Http/Controllers/Api/LogoController.php +++ b/app/Http/Controllers/Api/LogoController.php @@ -39,12 +39,6 @@ class LogoController extends ApiController ]); } - public function getLogoById($id){ - $airline = Airline::where('id', $id) - ->first(); - - return $this->getAirlineLogo($airline); - } public function getLogoByInternalName(string $internalName){ $airline = Airline::where('internal_name', $internalName) @@ -53,26 +47,4 @@ class LogoController extends ApiController return $this->getAirlineLogo($airline); } - - public function getLogoByCode(string $code){ - - $column = strlen($code) == 2 - ? 'IATA_code' - : 'ICAO_code'; - - $airline = Airline::where($column, strtoupper($code)) - ->whereNotNull('logo') - ->where('active', true) - ->latest('id') - ->first(); - - if (!$airline) { - $airline = Airline::where($column, strtoupper($code)) - ->whereNotNull('logo') - ->latest('id') - ->first(); - } - - return $this->getAirlineLogo($airline); - } } diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 5dded58..f9718ac 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -40,7 +40,7 @@ class UserController extends ApiController 'flightNumber' => $flight->flight_number, 'airlineName' => $flight->airline->name, 'aircraftType' => $flight->aircraft->manufacturer_code . ' ' . $flight->aircraft->model_full_name, - 'logoUrl' => config('app.logo_api_url') . "/airlines/logos/tail/name/{$flight->airline->internal_name}" + 'logoUrl' => $flight->airline->logo_url, ]; } diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0b7cf92..2bbf296 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -26,10 +26,11 @@ class SearchController extends Controller } }) ->limit(50) - ->get(['id', 'name', 'IATA_code', 'ICAO_code', 'logo']) + ->get() ->map(fn($airline) => [ 'value' => $airline->id, 'title' => $airline->display_name, + 'logo_url' => $airline->logo_url, ]) ->values(); } diff --git a/app/Models/Aircraft.php b/app/Models/Aircraft.php index f826765..3897652 100644 --- a/app/Models/Aircraft.php +++ b/app/Models/Aircraft.php @@ -23,6 +23,7 @@ class Aircraft extends Model protected $appends = [ 'display_name', + 'display_name_short' ]; protected function displayName() : Attribute{ @@ -32,4 +33,14 @@ class Aircraft extends Model } ); } + + protected function displayNameShort(): Attribute + { + return Attribute::make( + get: function () { + $name = "{$this->manufacturer_code} {$this->model_full_name}"; + return trim(preg_replace('/\s*\(.*?\)/', '', $name)); + } + ); + } } diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 122c061..e591f1f 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -29,6 +29,7 @@ class Airline extends Model public $timestamps = false; protected $appends = [ 'display_name', + 'logo_url', ]; protected function displayName() : Attribute{ @@ -41,6 +42,14 @@ class Airline extends Model ); } + protected function logoUrl() : Attribute{ + return Attribute::make( + get: function () { + return config('app.logo_api_url') . "/airline/$this->internal_name/logo/tail/"; + } + ); + } + public function country(): BelongsTo { return $this->belongsTo(Country::class); diff --git a/database/migrations/2026_04_22_060923_update_aircraft_table.php b/database/migrations/2026_04_22_060923_update_aircraft_table.php new file mode 100644 index 0000000..88fa2f3 --- /dev/null +++ b/database/migrations/2026_04_22_060923_update_aircraft_table.php @@ -0,0 +1,24 @@ +(); -const page = usePage().props; -const logoUrl = computed(() => `url('${page.logo_api_url}/airlines/logos/tail/name/${props.airline?.internal_name}')`); +const logoUrl = computed(() => `url('${props.airline?.logo_url}')`); const logoStyle = computed(() => ({ width: size.value, height: size.value, diff --git a/resources/js/Components/FlightsGoneBy/AirlineSearchBox.vue b/resources/js/Components/FlightsGoneBy/AirlineSearchBox.vue index 8c5b037..e38eab1 100644 --- a/resources/js/Components/FlightsGoneBy/AirlineSearchBox.vue +++ b/resources/js/Components/FlightsGoneBy/AirlineSearchBox.vue @@ -5,13 +5,13 @@ import {usePage} from "@inertiajs/vue3"; import type {SharedProps} from "@/Types/types"; const props = defineProps<{ - prefilledOptions: { value: number, title: string }[] + prefilledOptions: { value: number, title: string, logo_url: string }[] errorMessages?: string[] | string }>() const page = usePage().props -const model = defineModel<{ value: number, title: string } | null>() +const model = defineModel<{ value: number, title: string, logo_url: string } | null>() const airlineOptions = ref(props.prefilledOptions ?? []) const autocompleteRef = ref(null) @@ -58,13 +58,13 @@ const searchAirlines = async (query: string) => { style="padding: 0.25em" width="40" height="40" - :src="`${page.logo_api_url}/airlines/logos/tail/id/${model.value}`" + :src="`${model.logo_url}`" />