public function add_retreat($event_id = 0) { $staff = \montserrat\Contact::with('groups')->whereHas('groups', function ($query) { $query->where('group_id', '=', GROUP_ID_STAFF); })->orderBy('sort_name')->pluck('sort_name', 'id'); $retreats = \montserrat\Retreat::select(\DB::raw('CONCAT(idnumber, "-", title, " (",DATE_FORMAT(start_date,"%m-%d-%Y"),")") as description'), 'id')->orderBy('start_date', 'desc')->pluck('description', 'id'); $retreats->prepend('Unassigned', 0); $retreat = \montserrat\Retreat::findOrFail($event_id); // TODO: replace this with an autocomplete text box for performance rather than a dropdown box $participants = \montserrat\Registration::whereEventId($event_id)->whereCanceledAt(NULL)->get(); $current_user = Auth::user(); $user_email = \montserrat\Email::whereEmail($current_user->email)->first(); $defaults['event_id'] = $event_id; $defaults['event_description'] = $retreat->idnumber . '-' . $retreat->title . ' (' . $retreat->start_date . ')'; if (empty($user_email->contact_id)) { $defaults['user_id'] = 0; } else { $defaults['user_id'] = $user_email->contact_id; } return view('touchpoints.add_retreat', compact('staff', 'retreat', 'retreats', 'participants', 'defaults')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $registration = \montserrat\Registration::findOrFail($id); $retreat = \montserrat\Retreat::findOrFail($registration->event_id); \montserrat\Registration::destroy($id); $countregistrations = \montserrat\Registration::where('event_id', '=', $registration->event_id)->count(); //$retreat->attending = $countregistrations; $retreat->save(); return Redirect::action('RegistrationsController@index'); }
public function checkout($id) { /* checkout all registrations for a retreat where the arrived_at is not NULL and the departed is NULL for a particular event */ $retreat = \montserrat\Retreat::findOrFail($id); //verifies that it is a valid retreat id $registrations = \montserrat\Registration::whereEventId($id)->whereDepartedAt(NULL)->whereNotNull('arrived_at')->get(); foreach ($registrations as $registration) { $registration->departed_at = $registration->retreat_end_date; $registration->save(); } return Redirect::back(); }