Update PIREP statuses

This commit is contained in:
Nabeel Shahzad
2018-04-01 20:37:10 -05:00
parent 0f521c3af9
commit eb06c07fdb
3 changed files with 20 additions and 10 deletions

View File

@@ -173,7 +173,10 @@ class PirepController extends Controller
$attrs['user_id'] = $user->id;
$attrs['source'] = PirepSource::ACARS;
$attrs['state'] = PirepState::IN_PROGRESS;
$attrs['status'] = PirepStatus::INITIATED;
if (!array_key_exists('status', $attrs)) {
$attrs['status'] = PirepStatus::INITIATED;
}
$pirep = new Pirep($attrs);
@@ -290,7 +293,7 @@ class PirepController extends Controller
}
$attrs['state'] = PirepState::PENDING;
$attrs['status'] = PirepStatus::LANDED;
$attrs['status'] = PirepStatus::ARRIVED;
try {
$pirep = $this->pirepRepo->update($attrs, $id);
@@ -325,7 +328,8 @@ class PirepController extends Controller
Log::info('PIREP Cancel, user '.Auth::id(), $request->post());
$pirep = $this->pirepRepo->update([
'state' => PirepState::CANCELLED,
'state' => PirepState::CANCELLED,
'status' => PirepStatus::CANCELLED,
], $id);
return new PirepResource($pirep);
@@ -394,8 +398,11 @@ class PirepController extends Controller
++$count;
}
# Change the PIREP status
$pirep->status = PirepStatus::AIRBORNE;
# Change the PIREP status if it's as SCHEDULED before
if ($pirep->status === PirepStatus::INITIATED) {
$pirep->status = PirepStatus::AIRBORNE;
}
$pirep->save();
return $this->message($count.' positions added', $count);

View File

@@ -46,6 +46,7 @@ class UpdateRequest extends FormRequest
'block_off_time' => 'nullable|date',
'block_on_time' => 'nullable|date',
'created_at' => 'nullable|date',
'status' => 'nullable',
# See if the fare objects are included and formatted properly
'fares' => 'nullable|array',

View File

@@ -15,7 +15,7 @@ class PirepStatus extends Enum
public const SCHEDULED = 'SCH';
public const BOARDING = 'BST';
public const RDY_START = 'RDT';
public const OFF_BLOCK = 'OFB'; // Departed from gate
public const DEPARTED = 'OFB'; // Off block
public const RDY_DEICE = 'DIR';
public const STRT_DEICE = 'DIC';
public const GRND_RTRN = 'GRT';
@@ -24,14 +24,15 @@ class PirepStatus extends Enum
public const APPROACH = 'TEN';
public const ON_FINAL = 'FIN';
public const LANDED = 'LAN';
public const ON_BLOCK = 'ONB'; // Arrived to gate
public const ARRIVED = 'ONB'; // On block
public const CANCELLED = 'DX';
protected static $labels = [
PirepStatus::INITIATED => 'Initiated',
PirepStatus::SCHEDULED => 'Scheduled',
PirepStatus::BOARDING => 'Boarding',
PirepStatus::RDY_START => 'Ready for start',
PirepStatus::OFF_BLOCK => 'Off block',
PirepStatus::DEPARTED => 'Off block',
PirepStatus::RDY_DEICE => 'Ready for de-icing',
PirepStatus::STRT_DEICE => 'De-icing in progress',
PirepStatus::GRND_RTRN => 'Ground return',
@@ -39,7 +40,8 @@ class PirepStatus extends Enum
PirepStatus::DIVERTED => 'Diverted',
PirepStatus::APPROACH => 'Approach',
PirepStatus::ON_FINAL => 'Final approach',
PirepStatus::LANDED => 'Arrived',
PirepStatus::ON_BLOCK => 'On block',
PirepStatus::LANDED => 'Landed',
PirepStatus::ARRIVED => 'Arrived',
PirepStatus::CANCELLED => 'Cancelled',
];
}