/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show(Request $request) { $questions = ProfileQuestion::join('profiles_answers', 'profiles_questions.id', '=', 'profiles_answers.profile_question_id')->where('profiles_answers.user_id', $request->id)->get(); $user = User::with('achievements')->where('users.id', $request->id)->first(); //$users = User::where('category_id', 2)->where('id', '<>', Auth::user()->id)->get(); return view('members/show', ['user' => $user, 'questions' => $questions]); }
/** * Update the specified resource in storage. * * @return \Illuminate\Http\Response */ public function update() { $input = Input::except('_token'); foreach ($input as $key => $value) { $tag = ProfileQuestion::where('tag', $key)->firstOrFail(); $id = $tag->id; $answer = ProfileAnswer::where('profile_question_id', $id)->where('user_id', Auth::user()->id)->firstOrFail(); $answer->answer = $value; $answer->save(); } return Redirect::route('profile.index')->with('success', 'Profile updated!'); }