diff --git a/app/Database/migrations/2017_12_20_005147_create_acars_tables.php b/app/Database/migrations/2017_12_20_005147_create_acars_tables.php index a71b54df..8dc04db2 100644 --- a/app/Database/migrations/2017_12_20_005147_create_acars_tables.php +++ b/app/Database/migrations/2017_12_20_005147_create_acars_tables.php @@ -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); diff --git a/app/Http/Controllers/Api/PirepController.php b/app/Http/Controllers/Api/PirepController.php index 441248e5..d012f2d4 100644 --- a/app/Http/Controllers/Api/PirepController.php +++ b/app/Http/Controllers/Api/PirepController.php @@ -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(); diff --git a/app/Models/Acars.php b/app/Models/Acars.php index 4e270054..51212ec3 100644 --- a/app/Models/Acars.php +++ b/app/Models/Acars.php @@ -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', diff --git a/app/Models/Enums/AcarsType.php b/app/Models/Enums/AcarsType.php new file mode 100644 index 00000000..16bf60bf --- /dev/null +++ b/app/Models/Enums/AcarsType.php @@ -0,0 +1,13 @@ +