Add first pass of pirep import; additional fields in flight/pirep tables #114

This commit is contained in:
Nabeel Shahzad
2018-01-29 18:14:55 -06:00
parent 5c164e2cf6
commit a5f51f6264
10 changed files with 206 additions and 30 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models\Enums;
class FlightType extends EnumBase {
const PASSENGER = 0;
const CARGO = 1;
const CHARTER = 2;
protected static $labels = [
FlightType::PASSENGER => 'Passenger',
FlightType::CARGO => 'Cargo',
FlightType::CHARTER => 'Charter',
];
}

View File

@@ -11,9 +11,8 @@ class Flight extends BaseModel
public $table = 'flights';
public $incrementing = false;
protected $dates = ['deleted_at'];
public $fillable = [
'id',
'airline_id',
'flight_number',
'route_code',
@@ -21,11 +20,12 @@ class Flight extends BaseModel
'dpt_airport_id',
'arr_airport_id',
'alt_airport_id',
'route',
'dpt_time',
'arr_time',
'level',
'distance',
'flight_type',
'route',
'notes',
'has_bid',
'active',
@@ -35,6 +35,7 @@ class Flight extends BaseModel
'flight_number' => 'integer',
'level' => 'integer',
'distance' => 'float',
'flight_type' => 'integer',
'has_bid' => 'boolean',
'active' => 'boolean',
];

View File

@@ -23,6 +23,7 @@ class Pirep extends BaseModel
protected $dates = ['deleted_at'];
public $fillable = [
'id',
'user_id',
'flight_id',
'flight_number',
@@ -38,13 +39,18 @@ class Pirep extends BaseModel
'dpt_airport_id',
'arr_airport_id',
'fuel_used',
'landing_rate',
'source',
'level',
'route',
'notes',
'flight_type',
'state',
'status',
'source_name',
'raw_data',
'created_at',
'updated_at',
];
protected $casts = [
@@ -57,6 +63,8 @@ class Pirep extends BaseModel
'altitude' => 'integer',
'fuel_used' => 'float',
'gross_weight' => 'float',
'landing_rate' => 'float',
'flight_type' => 'integer',
'source' => 'integer',
'state' => 'integer',
'status' => 'integer',

View File

@@ -25,10 +25,8 @@ trait HashId
{
parent::boot();
static::creating(function ($model) {
$key = $model->getKeyName();
if (empty($model->{$key})) {
$id = static::createNewHashId();
$model->{$key} = $id;
if (empty($model->id)) {
$model->id = static::createNewHashId();
}
});
}

View File

@@ -47,6 +47,8 @@ class User extends Authenticatable
'timezone',
'state',
'status',
'created_at',
'updated_at',
];
/**