write the route if it hasn't been set by acars #184
This commit is contained in:
@@ -177,6 +177,7 @@ class PirepController extends RestController
|
|||||||
* @return PirepResource
|
* @return PirepResource
|
||||||
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function file($id, FileRequest $request)
|
public function file($id, FileRequest $request)
|
||||||
{
|
{
|
||||||
@@ -198,6 +199,15 @@ class PirepController extends RestController
|
|||||||
Log::error($e);
|
Log::error($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# See if there there is any route data posted
|
||||||
|
# If there isn't, then just write the route data from the
|
||||||
|
# route that's been posted from the PIREP
|
||||||
|
$w = ['pirep_id' => $pirep->id, 'type' => AcarsType::ROUTE];
|
||||||
|
$count = Acars::where($w)->count(['id']);
|
||||||
|
if($count === 0) {
|
||||||
|
$this->pirepSvc->saveRoute($pirep);
|
||||||
|
}
|
||||||
|
|
||||||
PirepResource::withoutWrapping();
|
PirepResource::withoutWrapping();
|
||||||
return new PirepResource($pirep);
|
return new PirepResource($pirep);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ class PIREPService extends BaseService
|
|||||||
* Save the route into the ACARS table with AcarsType::ROUTE
|
* Save the route into the ACARS table with AcarsType::ROUTE
|
||||||
* @param Pirep $pirep
|
* @param Pirep $pirep
|
||||||
* @return Pirep
|
* @return Pirep
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function saveRoute(Pirep $pirep): Pirep
|
public function saveRoute(Pirep $pirep): Pirep
|
||||||
{
|
{
|
||||||
@@ -111,13 +112,13 @@ class PIREPService extends BaseService
|
|||||||
'type' => AcarsType::ROUTE,
|
'type' => AcarsType::ROUTE,
|
||||||
])->delete();
|
])->delete();
|
||||||
|
|
||||||
# Delete the route
|
# See if a route exists
|
||||||
if (empty($pirep->route)) {
|
if (!filled($pirep->route)) {
|
||||||
return $pirep;
|
return $pirep;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$pirep->dpt_airport) {
|
if (!filled($pirep->dpt_airport)) {
|
||||||
Log::error('saveRoute: dpt_airport not found: '.$pirep->dpt_airport_id);
|
Log::error('saveRoute: dpt_airport not found: ' . $pirep->dpt_airport_id);
|
||||||
return $pirep;
|
return $pirep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<div class="form-group col-sm-6">
|
<div class="form-group col-sm-6">
|
||||||
{!! Form::label('timezone', 'Timezone:') !!}
|
{!! Form::label('timezone', 'Timezone:') !!}
|
||||||
{!! Form::select('timezone', $timezones, null, ['class' => 'select2']); !!}
|
{!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2']); !!}
|
||||||
<p class="text-danger">{{ $errors->first('timezone') }}</p>
|
<p class="text-danger">{{ $errors->first('timezone') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('a.airport_data_lookup').click(function(e) {
|
$('a.airport_data_lookup').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var icao = $("input#airport_icao").val();
|
const icao = $("input#airport_icao").val();
|
||||||
if(icao === '') {
|
if(icao === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -189,7 +189,7 @@ class AcarsTest extends TestCase
|
|||||||
# File the PIREP now
|
# File the PIREP now
|
||||||
$uri = '/api/pireps/'.$pirep_id.'/file';
|
$uri = '/api/pireps/'.$pirep_id.'/file';
|
||||||
$response = $this->post($uri, []);
|
$response = $this->post($uri, []);
|
||||||
$response->assertStatus(400); // missing the flight time
|
$response->assertStatus(400); // missing field
|
||||||
|
|
||||||
$response = $this->post($uri, ['flight_time' => '1:30']);
|
$response = $this->post($uri, ['flight_time' => '1:30']);
|
||||||
$response->assertStatus(400); // invalid flight time
|
$response->assertStatus(400); // invalid flight time
|
||||||
|
|||||||
Reference in New Issue
Block a user