diff --git a/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php b/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php index f32cba12..f18b3417 100644 --- a/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php +++ b/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php @@ -26,6 +26,7 @@ class CreatePirepTables extends Migration $table->char('flight_type', 1)->default(FlightType::SCHED_PAX); $table->string('dpt_airport_id', 4); $table->string('arr_airport_id', 4); + $table->string('alt_airport_id', 4)->nullable(); $table->unsignedInteger('level')->nullable(); $table->unsignedDecimal('distance')->nullable(); $table->unsignedDecimal('planned_distance')->nullable(); diff --git a/app/Http/Requests/Acars/PrefileRequest.php b/app/Http/Requests/Acars/PrefileRequest.php index 8344bbb2..cadd5e60 100644 --- a/app/Http/Requests/Acars/PrefileRequest.php +++ b/app/Http/Requests/Acars/PrefileRequest.php @@ -30,6 +30,7 @@ class PrefileRequest extends FormRequest 'arr_airport_id' => 'required', 'source_name' => 'required', + 'alt_airport_id' => 'nullable', 'status' => 'nullable', 'level' => 'nullable|numeric', 'flight_type' => 'nullable', diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index 4869f864..84613496 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -73,6 +73,7 @@ class Pirep extends Model 'route_leg', 'dpt_airport_id', 'arr_airport_id', + 'alt_airport_id', 'level', 'distance', 'planned_distance', @@ -168,6 +169,8 @@ class Pirep extends Model if (array_key_exists('block_off_time', $this->attributes)) { return new Carbon($this->attributes['block_off_time']); } + + return null; } /** @@ -180,6 +183,8 @@ class Pirep extends Model if (array_key_exists('block_on_time', $this->attributes)) { return new Carbon($this->attributes['block_on_time']); } + + return null; } /** @@ -192,6 +197,8 @@ class Pirep extends Model if (array_key_exists('submitted_at', $this->attributes)) { return new Carbon($this->attributes['submitted_at']); } + + return null; } /** @@ -228,7 +235,8 @@ class Pirep extends Model { if ($value instanceof Distance) { $this->attributes['distance'] = $value->toUnit( - config('phpvms.internal_units.distance')); + config('phpvms.internal_units.distance') + ); } else { $this->attributes['distance'] = $value; } @@ -361,7 +369,7 @@ class Pirep extends Model * * @param $value */ - public function setFuelUsedAttribute($value) + public function setFuelUsedAttribute($value): void { if ($value instanceof Fuel) { $this->attributes['fuel_used'] = $value->toUnit( @@ -377,7 +385,7 @@ class Pirep extends Model * * @param $value */ - public function setPlannedDistanceAttribute($value) + public function setPlannedDistanceAttribute($value): void { if ($value instanceof Distance) { $this->attributes['planned_distance'] = $value->toUnit( @@ -475,6 +483,11 @@ class Pirep extends Model return $this->belongsTo(Airport::class, 'arr_airport_id'); } + public function alt_airport() + { + return $this->belongsTo(Airport::class, 'alt_airport_id'); + } + public function dpt_airport() { return $this->belongsTo(Airport::class, 'dpt_airport_id');