Add more airlines and fix edit bugs
This commit is contained in:
+11
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Aircraft extends Model
|
||||
@@ -20,7 +21,15 @@ class Aircraft extends Model
|
||||
'engine_count' => 'integer',
|
||||
];
|
||||
|
||||
public function displayName() : string{
|
||||
return "{$this->manufacturer_code} {$this->model_full_name} ({$this->designator})";
|
||||
protected $appends = [
|
||||
'display_name',
|
||||
];
|
||||
|
||||
protected function displayName() : Attribute{
|
||||
return Attribute::make(
|
||||
get: function () {
|
||||
return "{$this->manufacturer_code} {$this->model_full_name} ({$this->designator})";
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-2
@@ -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
|
||||
|
||||
+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
|
||||
|
||||
@@ -6,5 +6,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SeatType extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
];
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user