Major refactoring for PIREP statuses and states to accomodate ACARS/route data
This commit is contained in:
10
app/Models/Acars.php
Normal file
10
app/Models/Acars.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Acars extends Model
|
||||
{
|
||||
public $table = 'acars';
|
||||
}
|
||||
28
app/Models/Enums/Days.php
Normal file
28
app/Models/Enums/Days.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
|
||||
class Days extends EnumBase {
|
||||
|
||||
const MONDAY = 1;
|
||||
const TUESDAY = 2;
|
||||
const WEDNESDAY = 4;
|
||||
const THURSDAY = 8;
|
||||
const FRIDAY = 16;
|
||||
const SATURDAY = 32;
|
||||
const SUNDAY = 64;
|
||||
|
||||
protected static $labels = [
|
||||
Days::MONDAY => 'Monday',
|
||||
Days::TUESDAY => 'Tuesday',
|
||||
Days::WEDNESDAY => 'Wednesday',
|
||||
Days::THURSDAY => 'Thursday',
|
||||
Days::FRIDAY => 'Friday',
|
||||
Days::SATURDAY => 'Saturday',
|
||||
Days::SUNDAY => 'Sunday',
|
||||
];
|
||||
}
|
||||
28
app/Models/Enums/EnumBase.php
Normal file
28
app/Models/Enums/EnumBase.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: nshahzad
|
||||
* Date: 12/19/17
|
||||
* Time: 8:04 PM
|
||||
*/
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
|
||||
/**
|
||||
* Class EnumBase
|
||||
* @package App\Models\Enums
|
||||
* TODO: Implement lang translations for enum labels
|
||||
*/
|
||||
class EnumBase
|
||||
{
|
||||
protected static $labels = [];
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function label($value) {
|
||||
return self::$labels[$value];
|
||||
}
|
||||
}
|
||||
22
app/Models/Enums/PirepSource.php
Normal file
22
app/Models/Enums/PirepSource.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: nshahzad
|
||||
* Date: 12/19/17
|
||||
* Time: 8:13 PM
|
||||
*/
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
|
||||
class PirepSource extends EnumBase
|
||||
{
|
||||
const MANUAL = 0;
|
||||
const ACARS = 1;
|
||||
|
||||
protected static $labels = [
|
||||
PirepSource::MANUAL => 'Manual',
|
||||
PirepSource::ACARS => 'ACARS',
|
||||
];
|
||||
|
||||
}
|
||||
17
app/Models/Enums/PirepState.php
Normal file
17
app/Models/Enums/PirepState.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class PirepState extends EnumBase {
|
||||
const REJECTED = -1;
|
||||
const PENDING = 0;
|
||||
const ACCEPTED = 1;
|
||||
|
||||
protected static $labels = [
|
||||
PirepState::REJECTED => 'Rejected',
|
||||
PirepState::PENDING => 'Pending',
|
||||
PirepState::ACCEPTED => 'Accepted',
|
||||
];
|
||||
}
|
||||
27
app/Models/Enums/PirepStatus.php
Normal file
27
app/Models/Enums/PirepStatus.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Enums for PIREP statuses
|
||||
*/
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
|
||||
/**
|
||||
* Tied to the ACARS statuses/states
|
||||
* Class PirepStatus
|
||||
* @package App\Models\Enums
|
||||
*/
|
||||
class PirepStatus extends EnumBase
|
||||
{
|
||||
const PREFILE = 0;
|
||||
const SCHEDULED = 0;
|
||||
const ENROUTE = 1;
|
||||
const ARRIVED = 2;
|
||||
|
||||
protected static $labels = [
|
||||
PirepStatus::PREFILE => 'Prefiled',
|
||||
PirepStatus::SCHEDULED => 'Scheduled',
|
||||
PirepStatus::ENROUTE => 'Enroute',
|
||||
PirepStatus::ARRIVED => 'Arrived',
|
||||
];
|
||||
}
|
||||
@@ -59,7 +59,11 @@ class Flight extends Model
|
||||
'arr_airport_id' => 'required',
|
||||
];
|
||||
|
||||
public function getFlightIdIataAttribute($value)
|
||||
/**
|
||||
* Get the flight ident, e.,g JBU1900
|
||||
* @param $value
|
||||
*/
|
||||
public function getIdentAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
10
app/Models/Navpoint.php
Normal file
10
app/Models/Navpoint.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Navpoint extends Model
|
||||
{
|
||||
public $table = 'navpoints';
|
||||
}
|
||||
@@ -37,6 +37,7 @@ class Pirep extends Model
|
||||
'level',
|
||||
'route',
|
||||
'notes',
|
||||
'state',
|
||||
'status',
|
||||
'raw_data',
|
||||
];
|
||||
@@ -52,6 +53,7 @@ class Pirep extends Model
|
||||
'level' => 'integer',
|
||||
'fuel_used' => 'integer',
|
||||
'source' => 'integer',
|
||||
'state' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
@@ -60,19 +62,19 @@ class Pirep extends Model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
'dpt_airport_id' => 'required',
|
||||
'arr_airport_id' => 'required',
|
||||
];
|
||||
public static $rules = [
|
||||
'dpt_airport_id' => 'required',
|
||||
'arr_airport_id' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the flight ident, e.,g JBU1900
|
||||
* @return string
|
||||
*/
|
||||
public function getFlightId()
|
||||
public function getIdentAttribute()
|
||||
{
|
||||
$flight_id = $this->airline->code;
|
||||
if($this->flight_id) {
|
||||
if ($this->flight_id) {
|
||||
$flight_id .= $this->flight->flight_number;
|
||||
} else {
|
||||
$flight_id .= $this->flight_number;
|
||||
|
||||
Reference in New Issue
Block a user