Updates an existing News model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
@throws ForbiddenHttpException if user can't edit this news
514756
public function actionUpdate($id, $activeTab = null)
    {
        $model = $this->findModel($id);

        if (!Yii::$app->user->can('roleNewsModerator') // user is not moderator
         &&  Yii::$app->user->can('roleNewsAuthor')    // but is author ...
         && !Yii::$app->user->can('updateOwnNews', [   // ... can edit only own post
                'news' => $model,                      //     - if post unvisible - always can
                'canEditVisible'                       //     - but if not visible - see this param
                    => $this->canAuthorEditOwnVisibleArticle,
            ])
        ) {
            if ($this->canAuthorEditOwnVisibleArticle) {
                throw new ForbiddenHttpException(Yii::t($this->tc, 'You can update only your own post'));
            } else {
                throw new ForbiddenHttpException(Yii::t($this->tc, 'You can update only your own post still unvisible'));
            }
        }

        //$modelsI18n = News::prepareI18nModels($model);
        $modelsI18n = $this->module->model('News')->prepareI18nModels($model);

        if (empty($activeTab)) $activeTab = $this->langCodeMain;

        $created = $this->savePost($model, $modelsI18n);

        if (!$created || ($activeTab = $this->modelsHaveErrors($model, $modelsI18n))) {
            return $this->render('update', [
                'model' => $model,
                'modelsI18n' => $modelsI18n,
                'activeTab' => $activeTab,
            ]);
        } else {
            Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Record save success'));
            if ($model->aftersave == $model::AFTERSAVE_VIEW) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                return $this->redirect(['index',
                    'page' => $model->page,
                    'id' => $model->id,
                    'sort' => $model->orderBy,
                    //'lang' => Yii::$app->language,
                ]);
            }
        }
    }
649772
public function actionDelete($id)
    {
        if (!\Yii::$app->user->can('delete'))
            throw new ForbiddenHttpException(Module::t('core', 'Access denied.'));

        $model = $this->findModel($id);
        $model->delete();
        // mark last comment in a thread
        \Yii::$app->db->createCommand("UPDATE {{%comment}} SET last=1 WHERE thread='{$model->thread}' ORDER BY created_at DESC LIMIT 1")->execute();

        return $this->redirect(['index']);
    }
1288946
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $oldSubmodulesParentUid = $model->parent_uid . '/{' . $model->id . '}';

        $post = Yii::$app->request->post();
        $loaded = $model->load($post);
        if ($loaded && $model->save()) {
            $newSubmodulesParentUid = $model->parent_uid . '/{' . $model->id . '}';
            $model->correctParents($oldSubmodulesParentUid, $newSubmodulesParentUid);

            //return $this->redirect(['view', 'id' => $model->id]);
            return $this->redirect(['index', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
537883
public function actionDisconnect($id) {
    $account = Account::find()->byId($id)->one();

    if ($account === null) {
      throw new NotFoundHttpException();
    }
    if ($account->userId != Yii::$app->user->id) {
      throw new ForbiddenHttpException();
    }

    $event = $this->getConnectEvent($account, $account->user);

    $this->trigger(self::EVENT_BEFORE_DISCONNECT, $event);
    $account->delete();
    $this->trigger(self::EVENT_AFTER_DISCONNECT, $event);

    return $this->redirect(['networks']);
  }
691741
public function actionUpdate($id)
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['update']);
        }
        try{
            $model = $this->findModel($id);
            if ($model->menuParent) {
                $model->parent_name = $model->menuParent->name;
            }
            if ($model->load(Yii::$app->request->post()) && $model->save()) {
                Helper::invalidate();
                return ["success"=> true];
            } else {
                return ["success"=> false];
            }
        }catch(Exception $e){
            throw new Exception($e);
        }
    }
189346
public function update($id)
    {
        try {
            $thread = Thread::findOrFail($id);
        } catch (ModelNotFoundException $e) {
            Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');

            return redirect()->route('messages');
        }

        $thread->activateAllParticipants();

        // Message
        Message::create([
            'thread_id' => $thread->id,
            'user_id' => Auth::id(),
            'body' => Input::get('message'),
        ]);

        // Add replier as a participant
        $participant = Participant::firstOrCreate([
            'thread_id' => $thread->id,
            'user_id' => Auth::id(),
        ]);
        $participant->last_read = new Carbon;
        $participant->save();

        // Recipients
        if (Input::has('recipients')) {
            $thread->addParticipant(Input::get('recipients'));
        }

        return redirect()->route('messages.show', $id);
    }
475671
public function update($id)
    {
        $block = $this->repository->getById($id);
        if (!empty($block)) {
            $this->authorize('update', $block);
            $input = $this->validator->validate('update');
            $block = $this->repository->update($block, $input, auth()->user());
            return $this->respondWithSuccess($block, new BlockTransformer);
        }
        return $this->respondNotFound();
    }
365257
public function updateAction($id) {
        $entity = $this->container->get("haven_core.category.read_handler")->getOne($id);
        $delete_form = $this->container->get("haven_core.category.form_handler")->createDeleteForm($id);
        $edit_form = $this->container->get("haven_core.category.form_handler")->createEditForm($id);

        $request = $this->container->get('request_modifier')->setRequest($this->container->get("request"))
                ->slug(array("name"))
                ->getRequest();

        $edit_form->bind($request);
        if ($edit_form->isValid()) {
            $this->container->get("haven_core.category.persistence_handler")->save($edit_form->getData());

            $this->container->get("session")->getFlashBag()->add("success", "update.success");
            return new RedirectResponse($this->container->get('router')->generate(str_replace('update', "edit", $this->container->get("request")->get("_route")), array("id" => $entity->getId())));
        }

        $this->container->get("session")->getFlashBag()->add("error", "update.error");

        $template = str_replace(":update.html.twig", ":edit.html.twig", $this->container->get("request")->get('_template'));
        $params = array(
            'entity' => $entity,
            'edit_form' => $edit_form->createView(),
            'delete_form' => $delete_form->createView(),
        );

        return new Response($this->container->get('templating')->render($template, $params));
    }
568807
public function actionUpdate($id)
    {
        $this->layout = static::FORM_LAYOUT;
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            $this->afterUpdate($model);

            if ($this->hasView) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                return $this->redirect(['index']);
            }
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
938922
public function update($id)
    {
        $input = Binput::only(['first_name', 'last_name', 'email']);

        $val = UserRepository::validate($input, array_keys($input));
        if ($val->fails()) {
            return Redirect::route('users.edit', ['users' => $id])
                ->withInput()->withErrors($val->errors());
        }

        $user = UserRepository::find($id);
        $this->checkUser($user);

        $email = $user['email'];

        $user->update($input);

        $groups = GroupRepository::index();

        $changed = false;

        foreach ($groups as $group) {
            if ($user->inGroup($group)) {
                if (Binput::get('group_'.$group->id) !== 'on') {
                    $user->removeGroup($group);
                    $changed = true;
                }
            } else {
                if (Binput::get('group_'.$group->id) === 'on') {
                    $user->addGroup($group);
                    $changed = true;
                }
            }
        }

        if ($email !== $input['email']) {
            $mail = [
                'old'     => $email,
                'new'     => $input['email'],
                'url'     => URL::to(Config::get('credentials.home', '/')),
                'subject' => Config::get('app.name').' - New Email Information',
            ];

            Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
                $message->to($mail['old'])->subject($mail['subject']);
            });

            Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
                $message->to($mail['new'])->subject($mail['subject']);
            });
        }

        if ($changed) {
            $mail = [
                'url'     => URL::to(Config::get('credentials.home', '/')),
                'email'   => $input['email'],
                'subject' => Config::get('app.name').' - Group Membership Changes',
            ];

            Mail::queue('credentials::emails.groups', $mail, function ($message) use ($mail) {
                $message->to($mail['email'])->subject($mail['subject']);
            });
        }

        return Redirect::route('users.show', ['users' => $user->id])
            ->with('success', 'The user has been updated successfully.');
    }
936530
public function update($id)
    {
        $data = Input::all();

        $isEditable = $this->isEditable($data);

        $data = $this->handleEditable($data);

        $data = $this->handleFileDelete($data);

        if ($this->handleOrderable($id, $data)) {
            return response([
                'status'  => true,
                'message' => trans('admin.update_succeeded'),
            ]);
        }

        /* @var Model $this->model */
        $this->model = $this->model->with($this->getRelations())->findOrFail($id);

        $this->setFieldOriginalValue();

        // Handle validation errors.
        if ($validationMessages = $this->validationMessages($data)) {
            if (!$isEditable) {
                //$name = str_replace('update','edit',\Route::currentRouteName());
                //return redirect()->route($name, [explode('.', $name)[0] => $id])->withInput()->withErrors($validationMessages);
                return back()->withInput()->withErrors($validationMessages);
            } else {
                return response()->json(['errors' => array_dot($validationMessages->getMessages())], 422);
            }
        }

        if (($response = $this->prepare($data)) instanceof Response) {
            return $response;
        }

        DB::transaction(function () {
            $updates = $this->prepareUpdate($this->updates);

            foreach ($updates as $column => $value) {
                /* @var Model $this->model */
                $this->model->setAttribute($column, $value);
            }

            $this->model->save();

            $this->updateRelation($this->relations);
        });

        if (($result = $this->complete($this->saved)) instanceof Response) {
            return $result;
        }

        if ($response = $this->ajaxResponse(trans('admin.update_succeeded'))) {
            return $response;
        }

        return $this->redirectAfterUpdate();
    }
423389
public function actionView($id = 0, $slug= '')
    {
        $model = $this->findModel($id, $slug);
        if (\Yii::$app->user->can('viewPost', ['post' => $model])) {
            return $this->render('view', [
                'model' => $model,
            ]);
        } else
            throw new ForbiddenHttpException(Module::t('core', 'Access denied.'));
    }
722273
public function update($id)
    {

        $model = ModuleRow::withoutGlobalScopes()->findOrFail($id);
        if (!request()->isMethod('put')) {
            $form = $this->form($model);
        } else {
            $input = Input::all();
            $user  = auth()->user();

            if (!$user->hasRoles('member')) {
                $model->user_id = array_get($input, 'user');
            }
            $model->name  = array_get($input, 'name');
            $model->value = array_only($input, ['field_1', 'field_2']);
            $form         = $this->form($model);

            if (!$form->isValid()) {
                return redirect_with_errors(handles('antares::sample_module/index/' . $id . '/edit'), $form->getMessageBag());
            }

            if (!$model->save()) {
                event('notifications.item_has_not_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
                return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_error'), 'error');
            }
            event('notifications.item_has_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);

            return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_success'), 'success');
        }

        return view('antares/sample_module::admin.module.create', ['form' => $form]);
    }
104190
public function update(?string $id)
    {
        $url = self::$base_url.'/'.($id ?? $this->container_id).'/update';

        $request = json_encode($request = $this->hostConfig);

        return self::$curl->post($url, $request, self::$header);
    }
113291
public function update(Update $request, $id)
    {
        try {
            $data = !$request->has('password') ? $request->except('password') : $this->inputAll();

            $user = $this->repository->findById($id);

            $user->update($data);

            $user->roles()->sync((array) \Input::get('role'));

            return $this->redirect('users.index');
        } catch (ModelNotFoundException $e) {
            return $this->redirectNotFound();
        }
    }
109842
public function update(Request $request, $id)
    {
        $this->validate($request, [
			'title' => 'required',
			'content' => 'required'
		]);
        $requestData = $request->all();
        
        $page = Page::findOrFail($id);
        $page->update($requestData);

        return redirect('admin/pages')->with('flash_message', 'Page updated!');
    }
258532
public function edit($id)
    {
        try {
            $role = $this->repository->findById($id);

            $permission_role = $role->permissions->lists('id');

            return $this->view('roles.edit', compact('role', 'permission_role'));
        } catch (ModelNotFoundException $e) {
            return $this->redirectNotFound();
        }
    }