diff --git a/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php b/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php index bdfec0c0..4fa8562a 100644 --- a/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php +++ b/app/Database/migrations/2017_06_28_195426_create_pirep_tables.php @@ -41,7 +41,7 @@ class CreatePirepTables extends Migration $table->unsignedTinyInteger('source')->nullable()->default(0); $table->string('source_name', 25)->nullable(); $table->tinyInteger('state')->default(PirepState::PENDING); - $table->tinyInteger('status')->default(PirepStatus::SCHEDULED); + $table->char('status', 3)->default(PirepStatus::SCHEDULED); $table->dateTime('block_off_time')->nullable(); $table->dateTime('block_on_time')->nullable(); $table->timestamps(); diff --git a/app/Http/Controllers/Api/PirepController.php b/app/Http/Controllers/Api/PirepController.php index ec955479..956cf371 100644 --- a/app/Http/Controllers/Api/PirepController.php +++ b/app/Http/Controllers/Api/PirepController.php @@ -173,7 +173,7 @@ class PirepController extends Controller $attrs['user_id'] = $user->id; $attrs['source'] = PirepSource::ACARS; $attrs['state'] = PirepState::IN_PROGRESS; - $attrs['status'] = PirepStatus::PREFILE; + $attrs['status'] = PirepStatus::INITIATED; $pirep = new Pirep($attrs); @@ -290,7 +290,7 @@ class PirepController extends Controller } $attrs['state'] = PirepState::PENDING; - $attrs['status'] = PirepStatus::ARRIVED; + $attrs['status'] = PirepStatus::LANDED; try { $pirep = $this->pirepRepo->update($attrs, $id); @@ -395,7 +395,7 @@ class PirepController extends Controller } # Change the PIREP status - $pirep->status = PirepStatus::ENROUTE; + $pirep->status = PirepStatus::AIRBORNE; $pirep->save(); return $this->message($count.' positions added', $count); diff --git a/app/Models/Enums/PirepStatus.php b/app/Models/Enums/PirepStatus.php index 162930e4..e84eec38 100644 --- a/app/Models/Enums/PirepStatus.php +++ b/app/Models/Enums/PirepStatus.php @@ -5,21 +5,41 @@ namespace App\Models\Enums; use App\Interfaces\Enum; /** - * Tied to the ACARS statuses/states - * Class PirepStatus + * Tied to the ACARS statuses/states. + * Corresponds to values from AIDX * @package App\Models\Enums */ class PirepStatus extends Enum { - public const PREFILE = 0; - public const SCHEDULED = 0; - public const ENROUTE = 1; - public const ARRIVED = 2; + public const INITIATED = 'INI'; + public const SCHEDULED = 'SCH'; + public const BOARDING = 'BST'; + public const RDY_START = 'RDT'; + public const OFF_BLOCK = 'OFB'; // Departed from gate + public const RDY_DEICE = 'DIR'; + public const STRT_DEICE = 'DIC'; + public const GRND_RTRN = 'GRT'; + public const AIRBORNE = 'TKO'; + public const DIVERTED = 'DV'; + public const APPROACH = 'TEN'; + public const ON_FINAL = 'FIN'; + public const LANDED = 'LAN'; + public const ON_BLOCK = 'ONB'; // Arrived to gate protected static $labels = [ - PirepStatus::PREFILE => 'Prefiled', - PirepStatus::SCHEDULED => 'Scheduled', - PirepStatus::ENROUTE => 'Enroute', - PirepStatus::ARRIVED => 'Arrived', + PirepStatus::INITIATED => 'Initiated', + PirepStatus::SCHEDULED => 'Scheduled', + PirepStatus::BOARDING => 'Boarding', + PirepStatus::RDY_START => 'Ready for start', + PirepStatus::OFF_BLOCK => 'Off block', + PirepStatus::RDY_DEICE => 'Ready for de-icing', + PirepStatus::STRT_DEICE => 'De-icing in progress', + PirepStatus::GRND_RTRN => 'Ground return', + PirepStatus::AIRBORNE => 'Enroute', + PirepStatus::DIVERTED => 'Diverted', + PirepStatus::APPROACH => 'Approach', + PirepStatus::ON_FINAL => 'Final approach', + PirepStatus::LANDED => 'Arrived', + PirepStatus::ON_BLOCK => 'On block', ]; } diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index 02363e91..5d72c725 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -93,7 +93,6 @@ class Pirep extends Model 'landing_rate' => 'float', 'source' => 'integer', 'state' => 'integer', - 'status' => 'integer', 'block_off_time' => 'datetime', 'block_on_time' => 'datetime', ]; diff --git a/tests/AcarsTest.php b/tests/AcarsTest.php index c091dc1e..1bf310ec 100644 --- a/tests/AcarsTest.php +++ b/tests/AcarsTest.php @@ -308,7 +308,7 @@ class AcarsTest extends TestCase # Check the PIREP state and status $pirep = $this->getPirep($pirep_id); $this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']); - $this->assertEquals(PirepStatus::PREFILE, $pirep['status']); + $this->assertEquals(PirepStatus::INITIATED, $pirep['status']); /** * Check the fields @@ -367,7 +367,7 @@ class AcarsTest extends TestCase # Make sure PIREP state moved into ENROUTE $pirep = $this->getPirep($pirep_id); $this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']); - $this->assertEquals(PirepStatus::ENROUTE, $pirep['status']); + $this->assertEquals(PirepStatus::AIRBORNE, $pirep['status']); $response = $this->get($uri); $response->assertStatus(200);