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) { Schema::create('acars', function (Blueprint $table) {
$table->string('id', 12); $table->string('id', 12);
$table->string('pirep_id', 12); $table->string('pirep_id', 12);
$table->unsignedTinyInteger('type');
$table->string('log')->nullable(); $table->string('log')->nullable();
$table->float('lat', 7, 4)->default(0.0); $table->float('lat', 7, 4)->default(0.0);
$table->float('lon', 7, 4)->default(0.0); $table->float('lon', 7, 4)->default(0.0);

View File

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

View File

@ -13,6 +13,7 @@ class Acars extends BaseModel
public $fillable = [ public $fillable = [
'pirep_id', 'pirep_id',
'type',
'log', 'log',
'lat', 'lat',
'lon', 'lon',
@ -27,6 +28,7 @@ class Acars extends BaseModel
]; ];
public $casts = [ public $casts = [
'type' => 'integer',
'lat' => 'float', 'lat' => 'float',
'lon' => 'float', 'lon' => 'float',
'heading' => 'integer', '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 <?php
/**
* Created by IntelliJ IDEA.
* User: nshahzad
* Date: 12/19/17
* Time: 8:04 PM
*/
namespace App\Models\Enums; namespace App\Models\Enums;
/** /**
* Class EnumBase * Class EnumBase
* @package App\Models\Enums * @package App\Models\Enums
@ -16,7 +9,6 @@ namespace App\Models\Enums;
class EnumBase class EnumBase
{ {
protected static $labels = []; protected static $labels = [];
protected static $adverbs = [];
/** /**
* Return the label, try to return the translated version as well * Return the label, try to return the translated version as well