Activates/enables a record.

@param ActivateRequest $request
@param int             $id
@return mixed
@event ModelActivatedInCms
@event ModelDeactivatedInCms
551331
public function activate(ActivateRequest $request, $id)
    {
        $record    = $this->modelRepository->findOrFail($id);
        $success   = false;
        $result    = null;
        $activated = $request->get('activate');

        if ($this->getModelInformation()->list->activatable) {
            $success = true;
            $result  = $this->changeModelActiveState($record, $activated);
        }

        if ($activated) {
            event( new Events\ModelActivatedInCms($record) );
        } else {
            event( new Events\ModelDeactivatedInCms($record) );
        }

        if (request()->ajax()) {
            return response()->json([ 'success' => $success, 'active' => $result ]);
        }

        if ($success && config('cms-models.notifications.flash.activate')) {
            cms_flash(
                cms_trans(
                    'models.store.success-message-' . ($result ? 'activate' : 'deactivate'),
                    [ 'record' => $this->getSimpleRecordReference($id, $record) ]
                ),
                FlashLevel::SUCCESS
            );
        }

        return redirect()->back();
    }
160460
public function destroy(Request $request, $id)
    {
        $this->model = $this->model->findOrFail($id);

        $deleted = $this->model->delete();

        $title = ucfirst(trans('livecms::livecms.destroysuccess'));
        $message = ucfirst(trans('livecms::livecms.destroysuccessmessage', ['model' => trans('livecms::livecms.'.$this->base)]));
        alert()->success($message, $title);

        if ($deleted) {
            return $this->redirection();
        }
    }
1166484
public function actionActivate($id)
    {
        /* @var $user User */
        $user = $this->findModel($id);
        if ($user->status == UserStatus::INACTIVE) {
            $user->status = UserStatus::ACTIVE;
            if ($user->save()) {
                return $this->goHome();
            } else {
                $errors = $user->firstErrors;
                throw new UserException(reset($errors));
            }
        }
        return $this->goHome();
    }
1368678
public function destroy(Request $request, $id)
    {
        $forceDelete = $request->get('force', false);

        $block = $this->repository->getByIdWithTrashed($id);

        if (!empty($block)) {
            $this->authorize('delete', $block);
            if ($forceDelete) {
                $this->repository->forceDelete($block);
            } else {
                $this->repository->delete($block);
            }
            return $this->respondWithSimpleSuccess(['success' => true]);
        }
        return $this->respondNotFound();
    }
317298
public function activate(Request $request)
    {
        if (!$email = $request->get('email')) {
            $email = null;
        }

        if (!$code = $request->get('code')) {
            $code = null;
        }

        if (!config('laraflock.dashboard.activations')) {
            Flash::error(trans('dashboard::dashboard.flash.activation.not_active'));

            return redirect()->route('auth.login');
        }

        return $this->view('auth.activate')->with(['email' => $email, 'code' => $code]);
    }
379018
public function update($id, Request $request)
    {
        return $this->updateModel($this->model()->find($id), $request->all(), 'edit');
    }
302652
public function destroy($id, Request $request)
    {
        $model = $this->model();

        $force = false;
        if (method_exists($model, 'forceDelete')) {
            $this->validate($request, ['force' => ['boolean']]);

            $model = $model->withTrashed();
            $force = (bool) $request->input('force');
        }

        return $this->deleteModel($model->find($id), 'delete', $force);
    }
925148
public function formAction($id, Request $request, $type = null)
    {
        $this->type = $type;

        return parent::formAction($id, $request);
    }
507428
public function update(Request $request, $id)
	{
		$entity = UUID::findOrFail($id)->entity;
		return ResourceController::resolveController($entity)->update($entity);
	}
204961
public function postEnableUserAction($id, Request $request)
    {
        $action = $request->get('action');

        try {
            switch ($action) {
                case 'enable':
                    // call repository method
                    $user = $this->getUserManager()->enableUser($id);
                    break;
                default:
                    throw new RestException('Unrecognized action: ' . $action);
            }

            // prepare view
            $view = $this->view($user, 200);
        } catch (RestException $exc) {
            $view = $this->view($exc->toArray(), 400);
        }

        $this->addSerializationGroups($view);

        return $this->handleView($view);
    }
634518
public function update(RemoveNewsletterUserRequest $request, $id)
    {
        $activated_at = ($request->input('activation') ? date('Y-m-d G:i:s') : null);
        $subscriber   = $this->subscriber->find($id);

        $new = $request->input('newsletter_id',[]);
        $has = $subscriber->subscriptions->pluck('id')->all();

        $added   = array_diff($new, $has);
        $removed = array_diff(array_unique(array_merge($new, $has)), $new);

        // if email edited we have to change it
        if($request->input('email') != $subscriber->email){
            // unsubscribe all and delete
            $this->subscription_worker->unsubscribe($subscriber,$has);

            // make new subscriber and add all
            $newsubscriber = $this->subscriber->create([
                'email' => $request->input('email'), 'activated_at' => $activated_at, 'activation_token' => md5($request->input('email').\Carbon\Carbon::now()),
            ]);

            $this->subscription_worker->subscribe($newsubscriber,$new);

            alert()->success('Abonné édité');
            return redirect('build/subscriber/'.$newsubscriber->id);
        }
        else{
            $subscriber = $this->subscriber->update(['id' => $id,'activated_at' => $request->input('activation') ? date('Y-m-d G:i:s') : null]);

            $this->subscription_worker->subscribe($subscriber,$added);
            $subscriber = $this->subscription_worker->unsubscribe($subscriber,$removed);

            if(!$subscriber){
                alert()->success('Abonné édité et supprimé');
                return redirect('build/subscriber');
            }

            alert()->success('Abonné édité');
            return redirect('build/subscriber/'.$subscriber->id);
        }
    }
747070
public function putActivate($id)
    {
        try
        {
            if ($this->users->activate($id))
            {
                // User activation passed
                return Redirect::route('cpanel.users.index')
                    ->with('success',Lang::get('cpanel::users.activation_success'));
            }
            else
            {
                // User activation failed
                return Redirect::route('cpanel.users.index')
                    ->with('error',Lang::get('cpanel::users.activation_fail'));
            }
        }
        catch (UserNotFoundException $e)
        {
            return Redirect::route('cpanel.users.index')
                ->with('error',$e->getMessage());
        }
    }
1245185
public function getAction($id, Request $request)
    {
        if ($this->getBooleanRequestParameter($request, 'tree', false, false)) {
            $collections = $this->getCollectionManager()->getTreeById(
                $id,
                $this->getRequestParameter($request, 'locale', true)
            );

            return $this->handleView(
                $this->view(
                    new CollectionRepresentation($collections, 'collections')
                )
            );
        }

        try {
            $locale = $this->getRequestParameter($request, 'locale', true);
            $depth = intval($request->get('depth', 0));
            $breadcrumb = $this->getBooleanRequestParameter($request, 'breadcrumb', false, false);
            $children = $this->getBooleanRequestParameter($request, 'children', false, false);
            $collectionManager = $this->getCollectionManager();

            // filter children
            $listRestHelper = $this->get('sulu_core.list_rest_helper');
            $limit = $request->get('limit', null);
            $offset = $this->getOffset($request, $limit);
            $search = $listRestHelper->getSearchPattern();
            $sortBy = $request->get('sortBy');
            $sortOrder = $request->get('sortOrder', 'ASC');

            $filter = [
                'limit' => $limit,
                'offset' => $offset,
                'search' => $search,
            ];

            $view = $this->responseGetById(
                $id,
                function($id) use ($locale, $collectionManager, $depth, $breadcrumb, $filter, $sortBy, $sortOrder, $children) {
                    $collection = $collectionManager->getById(
                        $id,
                        $locale,
                        $depth,
                        $breadcrumb,
                        $filter,
                        null !== $sortBy ? [$sortBy => $sortOrder] : [],
                        $children
                    );

                    if (SystemCollectionManagerInterface::COLLECTION_TYPE === $collection->getType()->getKey()) {
                        $this->get('sulu_security.security_checker')->checkPermission(
                            'sulu.media.system_collections',
                            PermissionTypes::VIEW
                        );
                    }

                    return $collection;
                }
            );
        } catch (CollectionNotFoundException $cnf) {
            $view = $this->view($cnf->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }

        return $this->handleView($view);
    }
404730
public function moveUpAction(Request $request, $id)
    {
        return parent::doMoveUpAction($this->getAdminListConfigurator(), $id, $request);
    }
1065238
public function deleteAction($id, Request $request)
    {
        $data = $this->resolveData($id);
        $title = $this->resolveDataTitle($data);

        $breadcrumbs = $this->buildBreadcrumbs($this->getType());
        $breadcrumbs->addItem(sprintf('Delete "%s"', $this->resolveDataTitle($data)));

        $form = $this->createForm(DeleteFormType::class, array(
            'id' => $data->getId(),
            'title' => $title,
        ));

        $form->handleRequest($request);

        if ($form->isValid()) {
            if ($form->get('tabs')->get('actions')->get('delete')->isClicked()) {
                $manager = $this->getDoctrine()->getManager();
                $manager->remove($data);
                $manager->flush();

                $request->getSession()
                    ->getFlashBag()
                    ->add('success', sprintf('You deleted "%s"!', $title));
            }

            if ($request->query->has('_return')) {
                $redirectUrl = $this->generateUrl($request->query->get('_return'));
            } else {
                $redirectUrl = $this->getListUrl();
            }

            return $this->redirect($redirectUrl);
        }

        $module = $this->getModule($this->getType());

        return $this->render('ClasticNodeBundle:Backoffice/Node:form.html.twig', array(
            'page_title' => sprintf('Delete "%s"?', $title),
            'form' => $form->createView(),
            'module' => $module,
            'submodules' => $this->getSubmodules($module),
        ));
    }
1299381
public function activate($id)
    {
        $user = $this->Users->get($id);
        $user->active = true;
        $this->Users->save($user);
        $this->Flash->success(I18N_OPERATION_OK);

        return $this->redirect(['action' => 'index']);
    }
1181464
public function update(Request $request, $id)
    {
        $entry = $this->entriesRepository->getById($id, $this->resource);
        $this->validate($request, $this->validationRules($this->resource, $entry));

        $this->entriesRepository->update($id, $request, $this->resource);

        return redirect()->back()->with('success', 'Updated');
    }