Add more airlines and fix edit bugs

This commit is contained in:
2026-04-18 16:45:13 +10:00
parent 63d6fb9e76
commit d90f338321
12 changed files with 111 additions and 28 deletions
+12 -2
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -26,9 +27,18 @@ class Airline extends Model
public $timestamps = false;
protected $appends = [
'display_name',
];
public function displayName() : string {
return "{$this->name} ({$this->IATA_code}/{$this->ICAO_code})";
protected function displayName() : Attribute{
return Attribute::make(
get: function () {
$codes = array_filter([$this->IATA_code, $this->ICAO_code]);
$codeString = count($codes) ? ' (' . implode('/', $codes) . ')' : '';
return "{$this->name}{$codeString}";
}
);
}
public function country(): BelongsTo