/** * Check to see if user is signed up for event. */ public function checkAvailability($id = null) { if ($id == null) { $id = $this->id; } $event = Event::find($id); $availability = $event->availability; $signed = DB::table('participants')->select('user_id')->where('event_id', '=', $event->id)->count(); $availability = $availability - $signed; if ($availability <= 0) { return false; } return true; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // Delete the event $event = Event::findOrFail($id); $event->delete(); // Delete all participants related to this event $participants = Participant::where('event_id', '=', $id); $participants->delete(); return redirect('event')->with('status', 'Boom! Event gone!'); }