From c89926399b86cb0d89e23f709e5c42c793dbe4b6 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Tue, 27 Feb 2018 13:14:58 -0600 Subject: [PATCH] Delete a bid by either the bid_id or the flight_id --- app/Http/Controllers/Api/UserController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index b7d41aa8..6fcf703a 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -93,6 +93,7 @@ class UserController extends RestController * Return all of the bids for the passed-in user * @param Request $request * @return mixed + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * @throws \App\Exceptions\BidExists * @throws \App\Services\Exception */ @@ -109,7 +110,13 @@ class UserController extends RestController } if ($request->isMethod('DELETE')) { - $flight_id = $request->input('flight_id'); + if($request->filled('bid_id')) { + $bid = UserBid::findOrFail($request->input('bid_id')); + $flight_id = $bid->flight_id; + } else { + $flight_id = $request->input('flight_id'); + } + $flight = $this->flightRepo->find($flight_id); $this->flightSvc->removeBid($flight, $user); }