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
+20 -2
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -27,8 +28,25 @@ class Airport extends Model
'elevation_ft' => 'integer',
];
public function displayName() : string{
return "{$this->municipality} / {$this->name} ({$this->iata_code}/{$this->icao_code})";
protected $appends = [
'display_code',
'display_name',
];
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->municipality} / {$this->name}{$codeString}";
}
);
}
protected function displayCode(): Attribute
{
return Attribute::make(
get: fn () => $this->iata_code ?? $this->icao_code ?? $this->local_code ?? '---'
);
}
public function region(): BelongsTo