function update($id) { $user = User::findorfail($id); $user->name = Input::get('name'); $user->email = Input::get('email'); //$user->password = Input::get('password'); //$user_info = DB::table('users_info')->where('user_id', $id)->get(); $user_info = UserInfo::where('user_id', $id)->first(); $user_info->style = Input::get('style'); $user_info->lang_one = Input::get('lang_one'); $user_info->lang_two = Input::get('lang_two'); $user_info->lang_three = Input::get('lang_three'); $user_info->csci_261 = Input::get('csci_261'); $user_info->csci_262 = Input::get('csci_262'); $user_info->csci_306 = Input::get('csci_306'); $user_info->csci_406 = Input::get('csci_406'); // save new updated information $user->save(); $user_info->save(); // redirect to /users/{id} return redirect('/users/' . $id); }
public function editInfo(Request $request) { UserInfo::where('user_id', Auth::user()->id)->update($request->except('_token')); return \Redirect()->back()->with(['flash_message' => 'Successfully saved !']); }
return redirect()->back(); // redirect back if current user tries to access another user } $user_info = UserInfo::where('user_id', $id)->first(); $user = User::findorfail($id); return view('pages/edit', compact('user', 'user_info')); }); Route::post('/users/{id}/edit', 'UserController@update'); // Password routes Route::controllers(['password' => 'Auth\\PasswordController']); // Admin routes - only accessible by admin user Route::group(['middleware' => 'App\\Http\\Middleware\\AdminMiddleware'], function () { Route::get('/admin', function () { $users = User::all(); $users_info = UserInfo::all(); $numTeams = count(Team::all()); $nullteam = UserInfo::where('team_id', null)->first(); return view('admin.teams', compact('users_info', 'users', 'numTeams', 'nullteam')); }); Route::post('/admin', 'AdminController@generate'); Route::get('/admin/generate', function () { return view('admin.generate'); }); Route::get('/admin/users/{id}', function ($id) { $user = User::findorfail($id); $userinfo = UserInfo::findorfail($id); $numTeams = count(Team::all()); return view('admin.user', compact('user', 'userinfo', 'numTeams')); }); Route::post('/admin/users/{id}', 'AdminController@edit'); });