Update account settings.

@param \Cortex\Auth\Http\Requests\Adminarea\AccountSettingsRequest $request

@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
551386
public function update(AccountSettingsRequest $request)
    {
        $data = $request->validated();
        $currentUser = $request->user($this->getGuard());

        ! $request->hasFile('profile_picture')
        || $currentUser->addMediaFromRequest('profile_picture')
                       ->sanitizingFileName(function ($fileName) {
                           return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION);
                       })
                       ->toMediaCollection('profile_picture', config('cortex.auth.media.disk'));

        ! $request->hasFile('cover_photo')
        || $currentUser->addMediaFromRequest('cover_photo')
                       ->sanitizingFileName(function ($fileName) {
                           return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION);
                       })
                       ->toMediaCollection('cover_photo', config('cortex.auth.media.disk'));

        // Update profile
        $currentUser->fill($data)->save();

        return intend([
            'back' => true,
            'with' => ['success' => trans('cortex/auth::messages.account.updated_account')]
                      + (isset($data['two_factor']) ? ['warning' => trans('cortex/auth::messages.verification.twofactor.phone.auto_disabled')] : []),
        ]);
    }
482271
public function index(GetSettingRequest $request)
    {
        $bundle = $this->repository->getBundle(new System(), $request->isDefault());
        return $this->sendResponse($bundle, 'System settings bundle');
    }
1294894
public function updateAction(ShopSetting $shopSetting, Request $request)
    {
        $editForm = $this->createForm(new ShopSettingType(), $shopSetting, array(
            'action' => $this->generateUrl('admin_amulen_shop_setting_update', array('id' => $shopSetting->getid())),
            'method' => 'PUT',
        ));
        if ($editForm->handleRequest($request)->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirect($this->generateUrl('admin_amulen_shop_setting_show', array('id' => $shopSetting->getId())));
        }
        $deleteForm = $this->createDeleteForm($shopSetting->getId(), 'admin_amulen_shop_setting_delete');

        return array(
            'shopSetting' => $shopSetting,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
476138
public function runUpdate(Request $request)
    {
        $user = User::find(Auth::id());
        $this->validate($request, [
            'old' => 'required',
            'password' => 'required|min:8|confirmed',
        ]);
        if (Auth::attempt(['name' => $user->name, 'password' => $request->old])) {
            $user->fill([ 'password' => bcrypt($request->password) ])->save();
            $request->session()->flash('success', 'Your password has been changed.');
            return redirect('/my-profile');
        }
        $request->session()->flash('failure', 'Your password has not been changed.');
        return redirect('/my-profile');
    }
521399
public function update(ChangePasswordRequest $request, Guard $auth)
    {
        try {
            $this->dispatch(new ChangePassword($auth->user()->id, $request->get('current_password'), $request->get('new_password')));
            return redirect()->route('authentication::profile.show');
        } catch (ValidationException $e) {
            return redirect()->back()->withErrors($e->errors());
        }
    }
940869
public function store(Request $request)
    {
        $setting = new Setting();

        
        $setting->name = $request->name;

        
        $setting->description = $request->description;

        
        
        $setting->save();

        return redirect('setting');
    }
1170499
public function update(ResetPasswordRequest $request)
    {
        try {
            $this->dispatch(new ResetPassword($request->get('token'), $request->get('email'), $request->get('password')));

            return redirect()->route('authentication::session.create')->withErrors([
                'authentication::password-reset.updated' => trans('authentication::password-reset.updated'),
            ]);
        } catch (TokenIsExpired $e) {
            return redirect()->route('authentication::password-reset.create')->withErrors([
                'authentication::password-reset.expired' => trans('authentication::password-reset.expired'),
            ]);
        }
    }
773231
public function updateAccounts(Models\Accounts $accounts)
    {
        $resource = 'accounts';
        $response = $this->sendPutRequest($resource, $accounts->toArray());
        $accountsResponse = new Models\UpdateAccountResponse($response);
        return $accountsResponse->getAccounts();
    }
825311
public function update(Request $request)
    {
        $this->authorize('update', Settings::class);

        $this->validate($request, [
            'text_editor' => 'required|in:plain-text,markdown,wysiwyg',
            'public_url'  => 'required|max:255',
        ]);

        Settings::first()->update([
            'text_editor' => $request->input('text_editor'),
            'public_url'  => $request->input('public_url'),
        ]);

        return redirect()->route('laralum::settings.index', ['p' => 'Tickets'])
            ->with('success', __('laralum_tickets::general.tickets_settings_updated'));
    }
326806
public function update_item( $request ) {
		$options = $this->get_registered_options();
		$params = $request->get_params();

		foreach ( $options as $name => $args ) {
			if ( ! array_key_exists( $name, $params ) ) {
				continue;
			}

			/**
			 * Filters whether to preempt a setting value update.
			 *
			 * Allow hijacking the setting update logic and overriding the built-in behavior by
			 * returning true.
			 *
			 * @since 4.7.0
			 *
			 * @param boolean $result Whether to override the default behavior for updating the
			 *                        value of a setting.
			 * @param string  $name   Setting name (as shown in REST API responses).
			 * @param mixed   $value  Updated setting value.
			 * @param array   $args   Arguments passed to `register_setting()` for this setting.
			 */
			$updated = apply_filters( 'rest_pre_update_setting', false, $name, $request[ $name ], $args );
			if ( $updated ) {
				continue;
			}

			// A null value means reset the option, which is essentially deleting it
			// from the database and then relying on the default value.
			if ( is_null( $request[ $name ] ) ) {
				delete_option( $args['option_name'] );
			} else {
				update_option( $args['option_name'], $request[ $name ] );
			}
		}

		return $this->get_item( $request );
	}
250139
public function update(LoggedUserEmailUpdate $request)
    {
        $user = Auth::user();
        if (! $this->checkCurrentPassword($request, $user)) {
            return new JsonResponse(
                [
                  'message'=> 'The given data was invalid.',
                  'errors'=> [
                    'current_password' => [ 'The password is not valid']
                  ]
                ],
                422
            );
        }
        $user->update(['email' => $request->email]);

        return $user;
    }
1306198
public function updateSettings(Request $request)
    {
        $this->authorize('update', Settings::class);

        Settings::first()->update([
            'stripe_key'    => $request->stripe_key ? encrypt($request->stripe_key) : null,
            'stripe_secret' => $request->stripe_secret ? encrypt($request->stripe_secret) : null,
        ]);

        return redirect()->route('laralum::settings.index', ['p' => 'Payments'])->with('success', __('laralum_payments::general.updated_settings'));
    }
916536
public function toggleProfileAction(Request $request)
    {
        $settingName = $this->getParameter('ongr_settings.active_profiles');
        $manager = $this->get('ongr_settings.settings_manager');

        #TODO Not sure where is the right place to put active profiles setting initiating
        if (!$manager->has($settingName)) {
            $manager->create(
                [
                    'name' => $settingName,
                    'value' => [],
                    'type' => 'hidden',
                ]
            );
        }

        $profileName = $request->get('name');
        $activeProfiles = (array)$manager->getValue($settingName, []);

        $key = array_search($profileName, $activeProfiles);
        if ($key === false) {
            $activeProfiles[] = $profileName;
        } else {
            unset($activeProfiles[$key]);
        }

        $manager->update($settingName, [
            'value' => array_values($activeProfiles)
        ]);

        $this->get('ong_settings.cache_provider')->deleteAll();

        return new JsonResponse(['error' => false]);
    }
187086
private function buildSettings(ServerRequestInterface $request, ResponseInterface $response): CorsSettings
    {
        $settings = new CorsSettings;

        $origin = array_fill_keys((array) $this->options["origin"], true);
        $settings->setRequestAllowedOrigins($origin);

        if (is_callable($this->options["methods"])) {
            $methods = (array) $this->options["methods"]($request, $response);
        } else {
            $methods = $this->options["methods"];
        }
        $methods = array_fill_keys($methods, true);
        $settings->setRequestAllowedMethods($methods);

        $headers = array_fill_keys($this->options["headers.allow"], true);
        $headers = array_change_key_case($headers, CASE_LOWER);
        $settings->setRequestAllowedHeaders($headers);

        $headers = array_fill_keys($this->options["headers.expose"], true);
        $settings->setResponseExposedHeaders($headers);

        $settings->setRequestCredentialsSupported($this->options["credentials"]);

        if (is_string($this->options["origin.server"])) {
            $settings->setServerOrigin($this->options["origin.server"]);
        }

        $settings->setPreFlightCacheMaxAge($this->options["cache"]);

        return $settings;
    }
1331165
public function update(Request $request)
    {
        $role = Role::findOrFail($request->role_id);

        $role->name = $request->name;

        $role->update();

        return redirect('scaffold-roles');
    }
648521
public function update(UpdateUserRequest $request, $id)
    {
        $user = User::find($id);
        $user->update($request->intersect(['email','name','password']));
        return Response::json(['updated' => true ]);
    }
471141
public function patchSettingsAction(Request $request)
    {
        $settings = $request->request->all();

        try {
            $user = $this->tokenStorage->getToken()->getUser();

            foreach ($settings as $settingKey => $settingValue) {
                // get setting
                // TODO: move this logic into own service (UserSettingManager?)
                $setting = $this->userSettingRepository->findOneBy(['user' => $user, 'key' => $settingKey]);

                // or create new one
                if (!$setting) {
                    $setting = new UserSetting();
                    $setting->setKey($settingKey);
                    $setting->setUser($user);
                    $this->objectManager->persist($setting);
                }

                // persist setting
                $setting->setValue(json_encode($settingValue));
            }
            $this->objectManager->flush();

            //create view
            $view = View::create($settings, 200);
        } catch (RestException $exc) {
            $view = View::create($exc->toArray(), 400);
        }

        return $this->viewHandler->handle($view);
    }