/** * This function gets the current mood info from Single page app and updates that into the database * @return mixed */ public function updateAPIWellbeing() { $input = Input::all(); $user = Auth::user(); $wellbeing = new Wellbeing(); $wellbeing->user_id = $user->id; $wellbeing->group_id = $input['groupid']; $wellbeing->task_id = 0; $wellbeing->mood = $input['mood']; $wellbeing->save(); $returnResponse = new stdClass(); $returnResponse->status = 'OK'; $returnResponse->message = 'Mood updated'; return Response::json($returnResponse); }
/** * */ public function updateWellbeing() { if (!$_POST) { App::abort(404); } $input = Input::all(); $wellbeing = new Wellbeing(); $wellbeing->user_id = $input['userid']; $wellbeing->group_id = $input['groupid']; $wellbeing->task_id = isset($input['taskid']) && !empty($input['taskid']) ? $input['taskid'] : ''; switch ($input['mood']) { case preg_match('/terrible/i', $input['mood']) == 1: $wellbeing->mood = 1; break; case preg_match('/not\\ great/i', $input['mood']) == 1: $wellbeing->mood = 2; break; case preg_match('/okay/i', $input['mood']) == 1: $wellbeing->mood = 3; break; case preg_match('/pretty\\ good/i', $input['mood']) == 1: $wellbeing->mood = 4; break; case preg_match('/fantastic/i', $input['mood']) == 1: $wellbeing->mood = 5; break; default: $wellbeing->mood = 1; break; } $wellbeing->save(); return Redirect::to('play/group/' . $input['groupid']); }