Add more airlines and fix edit bugs
This commit is contained in:
+20
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user