/** * Run the database seeds. * * @return void */ public function run() { // --------------------------------------------------------------------- // CONFERENCE 2 // --------------------------------------------------------------------- $conference = Conference::find(2); $vehicle = ['name' => 'Airport Taxi', 'passenger_count' => 0, 'capacity' => 7, 'type' => 'arrival']; $vehicle = new ConferenceVehicle($vehicle); $vehicle->conference()->associate($conference); $vehicle->save(); $vehicle = ['name' => 'Airport Taxi', 'passenger_count' => 0, 'capacity' => 7, 'type' => 'departure']; $vehicle = new ConferenceVehicle($vehicle); $vehicle->conference()->associate($conference); $vehicle->save(); $event = $conference->events()->first(); $vehicle = ['name' => 'Hotel Shuttle', 'passenger_count' => 0, 'capacity' => 50, 'type' => 'arrival']; $vehicle = new EventVehicle($vehicle); $vehicle->event()->associate($event); $vehicle->save(); $vehicle = ['name' => 'Hotel Shuttle', 'passenger_count' => 0, 'capacity' => 50, 'type' => 'departure']; $vehicle = new EventVehicle($vehicle); $vehicle->event()->associate($event); $vehicle->save(); }
/** * Delete a Passenger of a Conference Vehicle. * * @param Request $request * @param int $cid * @param int $vid * @param int $pid * @return Response */ public function destroy(Request $request, $cid, $vid, $pid) { try { $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $vehicle = ConferenceVehicle::find($vid); if (!$vehicle) { return response()->error(404, 'Vehicle Not Found'); } $profile = Profile::find($pid); if (!$profile) { return response()->error(404, 'Profile Not Found'); } $vehicle->passengers()->detach($profile); $vehicle->decrement('passenger_count'); return response()->success(); } catch (Exception $e) { return response()->error($e); } }
/** * Delete a Vehicle of a Conference. * * @param VehicleRequest $request * @param int $cid * @param int $vid * @return Response */ public function destroy(VehicleRequest $request, $cid, $vid) { try { $user = $this->isConferenceManager($request, $cid); if (!$user) { return response()->error(403, 'You are not a manager of this conference!'); } $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $vehicle = ConferenceVehicle::find($vid); if (!$vehicle) { return response()->error(404, 'Vehicle Not Found'); } $vehicle->delete(); return response()->success(); } catch (Exception $e) { return response()->error(); } }