Add AcarsType column and enum; save flight updates as FLIGHT_PATH #102

This commit is contained in:
Nabeel Shahzad 2018-01-01 10:30:31 -06:00
parent c65da0a0af
commit 078e26df57
5 changed files with 23 additions and 11 deletions

View File

@ -16,6 +16,7 @@ class CreateAcarsTables extends Migration
Schema::create('acars', function (Blueprint $table) {
$table->string('id', 12);
$table->string('pirep_id', 12);
$table->unsignedTinyInteger('type');
$table->string('log')->nullable();
$table->float('lat', 7, 4)->default(0.0);
$table->float('lon', 7, 4)->default(0.0);

View File

@ -2,21 +2,23 @@
namespace App\Http\Controllers\Api;
use App\Services\GeoService;
use Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Acars;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Http\Resources\Acars as AcarsResource;
use App\Http\Resources\Pirep as PirepResource;
use App\Services\GeoService;
use App\Services\PIREPService;
use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository;
use App\Http\Resources\Acars as AcarsResource;
use App\Http\Resources\Pirep as PirepResource;
use App\Http\Controllers\AppBaseController;
class PirepController extends AppBaseController
@ -178,7 +180,9 @@ class PirepController extends AppBaseController
Log::info('Posting ACARS update', $request->toArray());
$attrs = $request->toArray();
$attrs['pirep_id'] = $id;
$attrs['type'] = AcarsType::FLIGHT_PATH;
$update = Acars::create($attrs);
$update->save();

View File

@ -13,6 +13,7 @@ class Acars extends BaseModel
public $fillable = [
'pirep_id',
'type',
'log',
'lat',
'lon',
@ -27,6 +28,7 @@ class Acars extends BaseModel
];
public $casts = [
'type' => 'integer',
'lat' => 'float',
'lon' => 'float',
'heading' => 'integer',

View File

@ -0,0 +1,13 @@
<?php
namespace App\Models\Enums;
/**
* Class AcarsType
* @package App\Models\Enums
*/
class AcarsType extends EnumBase
{
const FLIGHT_PATH = 0;
const ROUTE = 1;
}

View File

@ -1,14 +1,7 @@
<?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
@ -16,7 +9,6 @@ namespace App\Models\Enums;
class EnumBase
{
protected static $labels = [];
protected static $adverbs = [];
/**
* Return the label, try to return the translated version as well