public function store_retreat(Request $request) { // $this->validate($request, ['event_id' => 'required|integer|min:0', 'touched_at' => 'required|date', 'staff_id' => 'required|integer|min:0', 'type' => 'in:Email,Call,Letter,Face,Other']); $event_id = $request->input('event_id'); $participants = \montserrat\Registration::whereEventId($event_id)->whereRoleId(PARTICIPANT_ROLE_ID_RETREATANT)->whereNull('canceled_at')->get(); foreach ($participants as $participant) { $touchpoint = new \montserrat\Touchpoint(); $touchpoint->person_id = $participant->contact_id; $touchpoint->staff_id = $request->input('staff_id'); $touchpoint->touched_at = Carbon::parse($request->input('touched_at')); $touchpoint->type = $request->input('type'); $touchpoint->notes = $request->input('notes'); $touchpoint->save(); } return Redirect::action('RetreatsController@show', $event_id); }
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(); }