public function updateprofile(Request $request) { $post = $request->all(); $validator = user::validateUpdateData($post); if ($validator->fails()) { return redirect()->back()->withErrors($validator->errors()); } else { $currentpassword = \Auth::user()->password; if (\Hash::check($post['password'], $currentpassword)) { unset($post['_token'], $post['password']); $result = user::where('id', $post['id'])->update($post); if ($result > 0) { Session::flash('message', 'profile successfully updated'); } return redirect('/'); } else { return redirect()->back()->withErrors('Wrong Password'); } } }