public function actionUpdate($id) { if (Yii::$app->user->can('editUser')) { $user = $this->findUser($id); $userEdit = new UserEdit(); $userEdit->attributes = $user->attributes; $userEdit->role = $user->role->item_name; if ($userEdit->load(Yii::$app->request->post())) { $userEdit->_oldEmail = $userEdit->email; $userEdit->_oldName = $userEdit->name; if ($userEdit->editUser($user)) { return $this->redirect(['admin/users']); } } return $this->render('update', ['userEdit' => $userEdit]); } else { throw new ForbiddenHttpException(); } }
public function postEditAccount() { if (Auth::check()) { $validation = \App\Models\UserEdit::Validate(Input::all()); if ($validation->passes()) { /** Here you have to edit table **/ $raw = 'UPDATE users SET telephone = "' . Input::get('telephone') . '", address = "' . Input::get('address') . '", mail = "' . Input::get('mail') . '" WHERE id = ' . Input::get('id'); DB::select(DB::raw($raw)); return Redirect::route('home')->with('message', 'Editing of account was successfull!'); } else { foreach (\App\Models\User::showAccount(Input::get('id')) as $value) { $my_user = $value; } return Redirect::route('editaccount')->withErrors($validation)->withInput()->with('user', $my_user); } } else { return Redirect::route('home')->with('message', 'You are not logged in!'); } }