Check if PIREP doesn't exist before cancelling

This commit is contained in:
Nabeel Shahzad
2022-02-16 19:13:47 -05:00
parent 08f82f8a2e
commit 648659aea5
2 changed files with 10 additions and 7 deletions

View File

@@ -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);
$this->pirepSvc->cancel($pirep);
if (!empty($pirep)) {
$this->pirepSvc->cancel($pirep);
}
return new PirepResource($pirep);
return $this->message('PIREP '.$pirep_id.' cancelled');
}
/**