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
+12 -5
View File
@@ -173,7 +173,10 @@ class PirepController extends Controller
$attrs['user_id'] = $user->id; $attrs['user_id'] = $user->id;
$attrs['source'] = PirepSource::ACARS; $attrs['source'] = PirepSource::ACARS;
$attrs['state'] = PirepState::IN_PROGRESS; $attrs['state'] = PirepState::IN_PROGRESS;
$attrs['status'] = PirepStatus::INITIATED;
if (!array_key_exists('status', $attrs)) {
$attrs['status'] = PirepStatus::INITIATED;
}
$pirep = new Pirep($attrs); $pirep = new Pirep($attrs);
@@ -290,7 +293,7 @@ class PirepController extends Controller
} }
$attrs['state'] = PirepState::PENDING; $attrs['state'] = PirepState::PENDING;
$attrs['status'] = PirepStatus::LANDED; $attrs['status'] = PirepStatus::ARRIVED;
try { try {
$pirep = $this->pirepRepo->update($attrs, $id); $pirep = $this->pirepRepo->update($attrs, $id);
@@ -325,7 +328,8 @@ class PirepController extends Controller
Log::info('PIREP Cancel, user '.Auth::id(), $request->post()); Log::info('PIREP Cancel, user '.Auth::id(), $request->post());
$pirep = $this->pirepRepo->update([ $pirep = $this->pirepRepo->update([
'state' => PirepState::CANCELLED, 'state' => PirepState::CANCELLED,
'status' => PirepStatus::CANCELLED,
], $id); ], $id);
return new PirepResource($pirep); return new PirepResource($pirep);
@@ -394,8 +398,11 @@ class PirepController extends Controller
++$count; ++$count;
} }
# Change the PIREP status # Change the PIREP status if it's as SCHEDULED before
$pirep->status = PirepStatus::AIRBORNE; if ($pirep->status === PirepStatus::INITIATED) {
$pirep->status = PirepStatus::AIRBORNE;
}
$pirep->save(); $pirep->save();
return $this->message($count.' positions added', $count); return $this->message($count.' positions added', $count);
@@ -46,6 +46,7 @@ class UpdateRequest extends FormRequest
'block_off_time' => 'nullable|date', 'block_off_time' => 'nullable|date',
'block_on_time' => 'nullable|date', 'block_on_time' => 'nullable|date',
'created_at' => 'nullable|date', 'created_at' => 'nullable|date',
'status' => 'nullable',
# See if the fare objects are included and formatted properly # See if the fare objects are included and formatted properly
'fares' => 'nullable|array', 'fares' => 'nullable|array',
+7 -5
View File
@@ -15,7 +15,7 @@ class PirepStatus extends Enum
public const SCHEDULED = 'SCH'; public const SCHEDULED = 'SCH';
public const BOARDING = 'BST'; public const BOARDING = 'BST';
public const RDY_START = 'RDT'; 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 RDY_DEICE = 'DIR';
public const STRT_DEICE = 'DIC'; public const STRT_DEICE = 'DIC';
public const GRND_RTRN = 'GRT'; public const GRND_RTRN = 'GRT';
@@ -24,14 +24,15 @@ class PirepStatus extends Enum
public const APPROACH = 'TEN'; public const APPROACH = 'TEN';
public const ON_FINAL = 'FIN'; public const ON_FINAL = 'FIN';
public const LANDED = 'LAN'; 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 = [ protected static $labels = [
PirepStatus::INITIATED => 'Initiated', PirepStatus::INITIATED => 'Initiated',
PirepStatus::SCHEDULED => 'Scheduled', PirepStatus::SCHEDULED => 'Scheduled',
PirepStatus::BOARDING => 'Boarding', PirepStatus::BOARDING => 'Boarding',
PirepStatus::RDY_START => 'Ready for start', PirepStatus::RDY_START => 'Ready for start',
PirepStatus::OFF_BLOCK => 'Off block', PirepStatus::DEPARTED => 'Off block',
PirepStatus::RDY_DEICE => 'Ready for de-icing', PirepStatus::RDY_DEICE => 'Ready for de-icing',
PirepStatus::STRT_DEICE => 'De-icing in progress', PirepStatus::STRT_DEICE => 'De-icing in progress',
PirepStatus::GRND_RTRN => 'Ground return', PirepStatus::GRND_RTRN => 'Ground return',
@@ -39,7 +40,8 @@ class PirepStatus extends Enum
PirepStatus::DIVERTED => 'Diverted', PirepStatus::DIVERTED => 'Diverted',
PirepStatus::APPROACH => 'Approach', PirepStatus::APPROACH => 'Approach',
PirepStatus::ON_FINAL => 'Final approach', PirepStatus::ON_FINAL => 'Final approach',
PirepStatus::LANDED => 'Arrived', PirepStatus::LANDED => 'Landed',
PirepStatus::ON_BLOCK => 'On block', PirepStatus::ARRIVED => 'Arrived',
PirepStatus::CANCELLED => 'Cancelled',
]; ];
} }