Updated logo API
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user