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')); }
public function edit_group($id) { // $registration = \montserrat\Registration::with('retreatant', 'retreat', 'room')->findOrFail($id); // $retreat = \montserrat\Retreat::findOrFail($registration->event_id); $retreatant = \montserrat\Contact::findOrFail($registration->contact_id); $retreats = \montserrat\Retreat::select(\DB::raw('CONCAT(idnumber, "-", title, " (",DATE_FORMAT(start_date,"%m-%d-%Y"),")") as description'), 'id')->where("end_date", ">", \Carbon\Carbon::today())->orderBy('start_date')->pluck('description', 'id'); //dd($retreats); //TODO: we will want to be able to switch between types when going from a group registration to individual room assignment if ($retreatant->contact_type == CONTACT_TYPE_INDIVIDUAL) { $retreatants = \montserrat\Contact::whereContactType(CONTACT_TYPE_INDIVIDUAL)->orderBy('sort_name')->pluck('sort_name', 'id'); } if ($retreatant->contact_type == CONTACT_TYPE_ORGANIZATION) { $retreatants = \montserrat\Contact::whereContactType(CONTACT_TYPE_ORGANIZATION)->whereSubcontactType($retreatant->subcontact_type)->orderBy('sort_name')->pluck('sort_name', 'id'); } $rooms = \montserrat\Room::orderby('name')->pluck('name', 'id'); $rooms->prepend('Unassigned', 0); /* Check to see if the current registration is for a past retreat and if so, add it to the collection */ // $retreats[0] = 'Unassigned'; if ($registration->retreat->end < \Carbon\Carbon::now()) { $retreats[$registration->event_id] = $registration->retreat->idnumber . '-' . $registration->retreat->title . " (" . date('m-d-Y', strtotime($registration->retreat->start_date)) . ")"; } return view('registrations.edit_group', compact('registration', 'retreats', 'rooms', 'retreatants')); }