Fix PIREP field error on file

This commit is contained in:
Nabeel Shahzad 2018-08-20 09:20:03 -05:00
parent 2dee3190ce
commit 5ee053cace
6 changed files with 15 additions and 8 deletions

View File

@ -132,7 +132,6 @@ class Handler extends ExceptionHandler
{
if ($request->expectsJson() || $request->is('api/*')) {
$error = $this->createError(401, 'Unauthenticated');
return response()->json($error, 401);
}
@ -159,8 +158,8 @@ class Handler extends ExceptionHandler
'exception' => $e,
'SKIN_NAME' => config('phpvms.skin'),
], $status, $e->getHeaders());
} else {
return $this->convertExceptionToResponse($e);
}
return $this->convertExceptionToResponse($e);
}
}

View File

@ -489,6 +489,7 @@ class PirepController extends Controller
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\PirepCancelled
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @throws \Exception
*/
public function route_post($id, RouteRequest $request)
{
@ -506,6 +507,10 @@ class PirepController extends Controller
$count = 0;
$route = $request->post('route', []);
if (\count($route) === 0) {
return $this->message('No points to add');
}
foreach ($route as $position) {
$position['pirep_id'] = $id;
$position['type'] = AcarsType::ROUTE;

View File

@ -21,12 +21,12 @@ class RouteRequest extends FormRequest
public function rules()
{
$rules = [
'route' => 'nullable|array',
/*'route.*.name' => 'required',
'route' => 'required|array',
'route.*.name' => 'required',
'route.*.order' => 'required|int',
'route.*.nav_type' => 'nullable|int',
'route.*.lat' => 'required|numeric',
'route.*.lon' => 'required|numeric',*/
'route.*.lon' => 'required|numeric',
];
return $rules;

View File

@ -1,9 +1,11 @@
<table class="table table-responsive table-hover" id="flight-fields-table">
@if(count($pirep->fields))
<thead>
<th></th>
<th>Value</th>
<th>Source</th>
</thead>
@endif
<tbody>
@foreach($pirep->fields as $field)
<tr>

View File

@ -270,7 +270,7 @@ flight reports that have been filed. You've been warned!
</div>
<div class="col-4">
@if(isset($pirep) && $pirep->fields)
<div class="form-container">
<h6><i class="fab fa-wpforms"></i>
&nbsp;{{ trans_choice('common.field', 2) }}
@ -282,7 +282,7 @@ flight reports that have been filed. You've been warned!
@each('pireps.custom_fields', $pirep->fields, 'field')
</div>
</div>
@endif
<div id="fares_container">
@include('pireps.fares')
</div>

View File

@ -643,6 +643,7 @@ class AcarsTest extends TestCase
$response = $this->post($uri, $pirep);
$pirep_id = $response->json()['data']['id'];
// Missing lat/lon
$post_route = ['order' => 1, 'name' => 'NAVPOINT'];
$uri = '/api/pireps/'.$pirep_id.'/route';
$response = $this->post($uri, $post_route);