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));

View File

@ -2,8 +2,9 @@
<thead>
<th>Subfleet</th>
<th>Name</th>
<th style="text-align: center;">ICAO</th>
{{--<th style="text-align: center;">ICAO</th>--}}
<th style="text-align: center;">Registration</th>
<th style="text-align: center;">Hours</th>
<th style="text-align: center;">Active</th>
<th style="text-align: right;"></th>
</thead>
@ -21,7 +22,10 @@
</td>
<td><a href="{!! route('admin.aircraft.edit', [$ac->id]) !!}">{!! $ac->name !!}</a></td>
<td style="text-align: center;">{!! $ac->icao !!}</td>
<td style="text-align: center;">{!! $ac->registration !!}</td>
{{--<td style="text-align: center;">{!! $ac->registration !!}</td>--}}
<td style="text-align: center;">
{!! Utils::minutesToTimeString($ac->flight_hours) !!}
</td>
<td style="text-align: center;">
@if($ac->active == GenericState::ACTIVE)
<span class="label label-success">{!! GenericState::label($ac->active); !!}</span>