Set airport and landing time of aircraft after pirep accept #112
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \App\Models\Enums\AircraftState;
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
@@ -12,14 +14,17 @@ class CreateAircraftsTable extends Migration
|
||||
$table->unsignedInteger('subfleet_id');
|
||||
$table->string('icao', 4)->nullable();
|
||||
$table->string('airport_id', 5)->nullable();
|
||||
$table->timestamp('landing_time')->nullable();
|
||||
$table->string('hex_code', 10)->nullable();
|
||||
$table->string('name', 50);
|
||||
$table->string('registration', 10)->nullable();
|
||||
$table->string('tail_number', 10)->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->unsignedTinyInteger('state')->default(AircraftState::PARKED);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique('registration');
|
||||
$table->index('airport_id');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
20
app/Models/Enums/AircraftState.php
Normal file
20
app/Models/Enums/AircraftState.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
/**
|
||||
* Class AircraftState
|
||||
* @package App\Models\Enums
|
||||
*/
|
||||
class AircraftState extends EnumBase
|
||||
{
|
||||
const PARKED = 0;
|
||||
const IN_USE = 1;
|
||||
const IN_AIR = 2;
|
||||
|
||||
public static $labels = [
|
||||
AircraftState::PARKED => 'On Ground',
|
||||
AircraftState::IN_USE => 'In Use',
|
||||
AircraftState::IN_AIR => 'In Air',
|
||||
];
|
||||
}
|
||||
@@ -267,6 +267,11 @@ class PIREPService extends BaseService
|
||||
|
||||
Log::info('PIREP ' . $pirep->id . ' state change to ACCEPTED');
|
||||
|
||||
# Update the aircraft
|
||||
$pirep->aircraft->airport_id = $pirep->arr_airport_id;
|
||||
$pirep->aircraft->landing_time = $pirep->updated_at;
|
||||
$pirep->aircraft->save();
|
||||
|
||||
event(new PirepAccepted($pirep));
|
||||
|
||||
return $pirep;
|
||||
|
||||
Reference in New Issue
Block a user