some acars/tables fixes
This commit is contained in:
@@ -68,8 +68,8 @@ class AcarsReplay extends Command
|
|||||||
'json' => [
|
'json' => [
|
||||||
'airline_id' => 1,
|
'airline_id' => 1,
|
||||||
'aircraft_id' => 1, # TODO: Lookup
|
'aircraft_id' => 1, # TODO: Lookup
|
||||||
'dpt_airport' => $flight->planned_depairport,
|
'dpt_airport_id' => $flight->planned_depairport,
|
||||||
'arr_airport' => $flight->planned_destairport,
|
'arr_airport_id' => $flight->planned_destairport,
|
||||||
'altitude' => $flight->planned_altitude,
|
'altitude' => $flight->planned_altitude,
|
||||||
'planned_flight_time' => $pft,
|
'planned_flight_time' => $pft,
|
||||||
'route' => $flight->planned_route,
|
'route' => $flight->planned_route,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CreateAcarsTables extends Migration
|
|||||||
$table->unsignedInteger('transponder')->nullable();
|
$table->unsignedInteger('transponder')->nullable();
|
||||||
$table->string('autopilot')->nullable();
|
$table->string('autopilot')->nullable();
|
||||||
$table->decimal('fuel_flow')->nullable();
|
$table->decimal('fuel_flow')->nullable();
|
||||||
$table->dateTimeTz('sim_time')->nullable();
|
$table->string('sim_time')->nullable();
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class PirepController extends AppBaseController
|
|||||||
$attr['user_id'] = Auth::user()->id;
|
$attr['user_id'] = Auth::user()->id;
|
||||||
$attr['airline_id'] = $request->get('airline_id');
|
$attr['airline_id'] = $request->get('airline_id');
|
||||||
$attr['aircraft_id'] = $request->get('aircraft_id');
|
$attr['aircraft_id'] = $request->get('aircraft_id');
|
||||||
$attr['dpt_airport_id'] = $request->get('dpt_airport');
|
$attr['dpt_airport_id'] = $request->get('dpt_airport_id');
|
||||||
$attr['arr_airport_id'] = $request->get('arr_airport');
|
$attr['arr_airport_id'] = $request->get('arr_airport_id');
|
||||||
$attr['altitude'] = $request->get('altitude');
|
$attr['altitude'] = $request->get('altitude');
|
||||||
$attr['route'] = $request->get('route');
|
$attr['route'] = $request->get('route');
|
||||||
$attr['notes'] = $request->get('notes');
|
$attr['notes'] = $request->get('notes');
|
||||||
@@ -89,9 +89,7 @@ class PirepController extends AppBaseController
|
|||||||
*/
|
*/
|
||||||
public function acars_get($id)
|
public function acars_get($id)
|
||||||
{
|
{
|
||||||
$pirep = $this->pirepRepo->find($id);
|
$updates = $this->acarsRepo->forPirep($this->pirepRepo->find($id));
|
||||||
|
|
||||||
$updates = $this->acarsRepo->forPirep($id);
|
|
||||||
return new AcarsResource($updates);
|
return new AcarsResource($updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,16 @@ class Acars extends BaseModel
|
|||||||
'sim_time',
|
'sim_time',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $casts = [
|
||||||
|
'lat' => 'float',
|
||||||
|
'lon' => 'float',
|
||||||
|
'heading' => 'integer',
|
||||||
|
'altitude' => 'integer',
|
||||||
|
'vs' => 'float',
|
||||||
|
'gs' => 'float',
|
||||||
|
'fuel_flow' => 'float',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FKs
|
* FKs
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class SettingRepository extends BaseRepository implements CacheableInterface
|
|||||||
{
|
{
|
||||||
use CacheableRepository;
|
use CacheableRepository;
|
||||||
|
|
||||||
|
public $cacheMinutes = 1;
|
||||||
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return Setting::class;
|
return Setting::class;
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ class AcarsTest extends TestCase
|
|||||||
$pirep = [
|
$pirep = [
|
||||||
'airline_id' => $airline->id,
|
'airline_id' => $airline->id,
|
||||||
'aircraft_id' => $aircraft->id,
|
'aircraft_id' => $aircraft->id,
|
||||||
'dpt_airport' => $airport->icao,
|
'dpt_airport_id' => $airport->icao,
|
||||||
'arr_airport' => $airport->icao,
|
'arr_airport_id' => $airport->icao,
|
||||||
'altitude' => 38000,
|
'altitude' => 38000,
|
||||||
'planned_flight_time' => 120,
|
'planned_flight_time' => 120,
|
||||||
'route' => 'POINTA POINTB',
|
'route' => 'POINTA POINTB',
|
||||||
@@ -92,4 +92,27 @@ class AcarsTest extends TestCase
|
|||||||
$response = $this->withHeaders($this->apiHeaders())->post($uri, $acars);
|
$response = $this->withHeaders($this->apiHeaders())->post($uri, $acars);
|
||||||
$response->assertStatus(404);
|
$response->assertStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAcarsIsoDate()
|
||||||
|
{
|
||||||
|
$pirep = factory(App\Models\Pirep::class)->make()->toArray();
|
||||||
|
$uri = '/api/pirep/prefile';
|
||||||
|
$response = $this->withHeaders($this->apiHeaders())->post($uri, $pirep);
|
||||||
|
$pirep_id = $response->json()['id'];
|
||||||
|
|
||||||
|
$dt = date('c');
|
||||||
|
$uri = '/api/pirep/' . $pirep_id . '/acars';
|
||||||
|
$acars = factory(App\Models\Acars::class)->make()->toArray();
|
||||||
|
$acars['sim_time'] = $dt;
|
||||||
|
|
||||||
|
$response = $this->withHeaders($this->apiHeaders())->post($uri, $acars);
|
||||||
|
$response->assertStatus(201);
|
||||||
|
|
||||||
|
$uri = '/api/pirep/' . $pirep_id . '/acars';
|
||||||
|
$response = $this->withHeaders($this->apiHeaders())->get($uri);
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$body = $response->json();
|
||||||
|
$this->assertEquals($dt, $body[0]['sim_time']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user