Check if PIREP doesn't exist before cancelling
This commit is contained in:
parent
08f82f8a2e
commit
648659aea5
@ -87,16 +87,17 @@ abstract class Controller extends \Illuminate\Routing\Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function message($message, $count = null)
|
||||
public function message($message, $count = null, $attrs = [])
|
||||
{
|
||||
$attrs = [
|
||||
$ret = [
|
||||
'message' => $message,
|
||||
'attrs' => $attrs,
|
||||
];
|
||||
|
||||
if ($count !== null) {
|
||||
$attrs['count'] = $count;
|
||||
$ret['count'] = $count;
|
||||
}
|
||||
|
||||
return response()->json($attrs);
|
||||
return response()->json($ret);
|
||||
}
|
||||
}
|
||||
|
@ -334,16 +334,18 @@ class PirepController extends Controller
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*
|
||||
* @return PirepResource
|
||||
* @return mixed
|
||||
*/
|
||||
public function cancel($pirep_id, Request $request)
|
||||
{
|
||||
Log::info('PIREP '.$pirep_id.' Cancel, user '.Auth::id(), $request->post());
|
||||
|
||||
$pirep = Pirep::find($pirep_id);
|
||||
if (!empty($pirep)) {
|
||||
$this->pirepSvc->cancel($pirep);
|
||||
}
|
||||
|
||||
return new PirepResource($pirep);
|
||||
return $this->message('PIREP '.$pirep_id.' cancelled');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user