Track hours on aircraft #73

This commit is contained in:
Nabeel Shahzad
2018-01-11 22:00:39 -06:00
parent fe4f39a5dc
commit e3bce1cd69
3 changed files with 11 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ class CreateAircraftsTable extends Migration
$table->string('name', 50);
$table->string('registration', 10)->nullable();
$table->string('tail_number', 10)->nullable();
$table->unsignedBigInteger('flight_time')->default(0);
$table->boolean('active')->default(true);
$table->unsignedTinyInteger('state')->default(AircraftState::PARKED);
$table->timestamps();

View File

@@ -268,6 +268,7 @@ class PIREPService extends BaseService
Log::info('PIREP ' . $pirep->id . ' state change to ACCEPTED');
# Update the aircraft
$pirep->aircraft->flight_time += $pirep->flight_time;
$pirep->aircraft->airport_id = $pirep->arr_airport_id;
$pirep->aircraft->landing_time = $pirep->updated_at;
$pirep->aircraft->save();
@@ -300,6 +301,9 @@ class PIREPService extends BaseService
$pirep->save();
$pirep->refresh();
$pirep->aircraft->flight_time -= $pirep->flight_time;
$pirep->aircraft->save();
Log::info('PIREP ' . $pirep->id . ' state change to REJECTED');
event(new PirepRejected($pirep));