delete the user bids when a flight is deleted #103

This commit is contained in:
Nabeel Shahzad
2018-01-01 09:32:04 -06:00
parent 904f64939f
commit c65da0a0af
5 changed files with 89 additions and 19 deletions

View File

@@ -16,6 +16,18 @@ use App\Models\UserBid;
class FlightService extends BaseService
{
/**
* Delete a flight, and all the user bids, etc associated with it
* @param Flight $flight
* @throws \Exception
*/
public function deleteFlight(Flight $flight)
{
$where = ['flight_id' => $flight->id];
UserBid::where($where)->delete();
$flight->delete();
}
/**
* Allow a user to bid on a flight. Check settings and all that good stuff
* @param Flight $flight