Изменение дополнительных параметров у прикрепленных фото.

@param Request $request
@return \Illuminate\Http\JsonResponse
491934
public function CustomProperties(Request $request)
    {
        if (! $request->has('id')) {
            return response()->json(['status' => 'error', 'message' => trans('larrock::apps.param.404', ['name' => 'id'])], 400);
        }
        $id = $request->get('id'); //ID в таблице media
        $media = DB::table('media')->where('id', $id)->first();
        if ($media && DB::table('media')
            ->where('id', $id)
            ->update(['order_column' => $request->get('position', 0),
                'custom_properties' => json_encode([
                    'alt' => $request->get('alt'),
                    'gallery' => $request->get('gallery'), ]), ])) {
            Cache::forget(sha1('loadMediaCache'.$request->get('gallery').$id.$media->model_type));

            return response()->json(['status' => 'success', 'message' => trans('larrock::apps.data.update', ['name' => 'параметров'])]);
        }

        return response()->json(['status' => 'error', 'message' => trans('larrock::apps.row.error')], 400);
    }
1209502
public function toResponse($request)
	{
		return new JsonResponse([
			'data' => $this->transformData($request),
			'meta' => [
				'pagination' => [
					'total' => $this->paginator->total(),
					'per_page' => $this->paginator->perPage(),
					'current_page' => $this->paginator->currentPage(),
					'total_pages' => $this->paginator->lastPage()
				]
			]
		]);
	}
441104
public function post(Request $request)
    {
        $userData = $this->getContentAsArray($request);

        $errors = $this->userRegistrationValidator->validate($userData ?: []);

        if (count($errors) > 0) {
            return $this->createConstraintViolationResponse($errors);
        }

        try {
            $newUser = $this->userService->register($userData);
        } catch (OutOfBoundsException $e) {
            return $this->createEmailNotUniqueResponse();
        }

        $newUser = $this->userArrayWithoutPassword($newUser);

        $newUser['_href'] = $this->url('user-entity', array('user' => $newUser['id']));

        return $this->createJsonResponse($newUser, 201);
    }
1135669
public function getClientsByTypesAction(Request $request)
    {
        $types = $request->get('types');

        if (!$types) {
            return new JsonResponse();
        }

        $clients = $this->getClientsByTypes($types);

        return new JsonResponse($clients);
    }
652358
public function run(Request $request) {
		$login = '';
		$error = '';
		$redirect = $request->headers->get('referer');
		$prefs = $this->getServiceContainer()->getPreferenceLoader()->getSystemPreferences();

		// try login
		if ($request->isMethod('POST')) {
			$login = $request->request->get('login');
			$password = $request->request->get('password');
			$redirect = rawurldecode($request->request->get('redirect'));

			$auth = $this->getServiceContainer()->getAuthManager();
			if ($auth->login($login, $password)) {
				$token = $auth->getSession()->getToken();
				$foward = $redirect ?: $prefs->getAccountUrl();
				$response = new RedirectResponse($foward);
				$this->getServiceContainer()->getKernel()->setCookie($response, AuthManager::COOKIE_TOKEN_NAME, $token);
				return $response;
			}

			$error = 'Invalid credentials';
		}

		$translator = $this->getServiceContainer()->getTranslator();
		$module = $this->getModule();
		$form = $module->getWidgetFactory()->createLoginWidget();
		$form = $form->build([
			'error' => $error,
			'destination' => $prefs->getAccountUrl() . '/' . $translator->trans('slug.login'),
			'redirect' => $redirect,
			'login' => $login
		]);

		return $this->responder->run($request, new Blank([
			'form' => $form
		]));
	}
1321452
public function addTranslationAction(Request $request): Response
    {
        $form = $this->contentTypeFormFactory->addContentTypeTranslation(
            new TranslationAddData()
        );
        $form->handleRequest($request);

        /** @var TranslationAddData $data */
        $data = $form->getData();
        $contentType = $data->getContentType();
        $contentTypeGroup = $data->getContentTypeGroup();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (TranslationAddData $data) {
                $contentType = $data->getContentType();
                $language = $data->getLanguage();
                $baseLanguage = $data->getBaseLanguage();
                $contentTypeGroup = $data->getContentTypeGroup();

                try {
                    $contentTypeDraft = $this->tryToCreateContentTypeDraft($contentType);
                } catch (BadStateException $e) {
                    $userId = $contentType->modifierId;
                    $this->notificationHandler->error(
                        $this->translator->trans(
                            /** @Desc("Draft of the Content Type '%name%' already exists and is locked by '%userContentName%'") */
                            'content_type.edit.error.already_exists',
                            ['%name%' => $contentType->getName(), '%userContentName%' => $this->getUserNameById($userId)],
                            'content_type'
                        )
                    );

                    return $this->redirectToRoute('ezplatform.content_type.view', [
                        'contentTypeGroupId' => $contentTypeGroup->id,
                        'contentTypeId' => $contentType->id,
                    ]);
                }

                return new RedirectResponse($this->generateUrl('ezplatform.content_type.update', [
                    'contentTypeId' => $contentTypeDraft->id,
                    'contentTypeGroupId' => $contentTypeGroup->id,
                    'fromLanguageCode' => null !== $baseLanguage ? $baseLanguage->languageCode : null,
                    'toLanguageCode' => $language->languageCode,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirectToRoute('ezplatform.content_type.view', [
            'contentTypeGroupId' => $contentTypeGroup->id,
            'contentTypeId' => $contentType->id,
        ]);
    }
573742
public function postAction(Request $request)
    {
        try {
            return $this->createJsonResponse($this->get('oauth.server')->grant(
                $this->getRequestData($request, 'snakelize')
            ));
        } catch (InvalidGrantException $e) {
            return new JsonResponse('Unavailable to create access token : bad credentials.', 401);
        } catch (\InvalidArgumentException $e) {
            return new JsonResponse('Invalid or missing fields for grant type.', 400);
        }
    }
347723
public function allAction(Request $request)
    {
        $model = $this->getModel();

        $content = $this->restUtils->serialize($model->findAll($request));

        $response = $this->getResponse()
            ->setStatusCode(Response::HTTP_OK)
            ->setContent($content);

        return $response;
    }
488624
public function call(Request $request)
    {
        if($request !== $this->getRequestStack()->getCurrentRequest()){
            $this->getRequestStack()->push($request);
        }

        if(!$request->getRequestFormat(null) && $request->getAcceptableContentTypes()){
            $request->setRequestFormat($request->getFormat($request->getAcceptableContentTypes()[0]));
        }

        $response = $this->getRouter()
                ->find($request)
                ->call($this->getServices());

        if($response instanceof Response){
            return $response;
        }
        return new Response($response);
    }
213072
public function getAction(Request $request)
    {
        $structureProvider = $this->get('sulu.content.structure_manager');
        $type = $request->get('type', 'default');

        $templates = [];
        foreach ($structureProvider->getStructures('article') as $structure) {
            if ($this->getType($structure->getStructure()) !== $type) {
                continue;
            }

            $templates[] = [
                'internal' => $structure->getInternal(),
                'template' => $structure->getKey(),
                'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()),
            ];
        }

        return new JsonResponse(
            [
                '_embedded' => $templates,
                'total' => count($templates),
            ]
        );
    }
11158
protected function send(Request $request)
    {
        try {
            $response = $this->client->send($request);
        } catch (ClientException $e) {
            $response = $e->getResponse();
        } catch (ServerException $e) {
            $response = $e->getResponse();
        }

        return $response;
    }
736124
public function postAction(Request $request)
    {
        $type = 'page';
        $language = $this->getLanguage($request);
        $action = $request->get('action');

        $this->checkActionParameterSecurity($action, $language);

        $document = $this->getDocumentManager()->create($type);
        $formType = $this->getMetadataFactory()->getMetadataForAlias($type)->getFormType();

        $this->persistDocument($request, $formType, $document, $language);
        $this->handleActionParameter($action, $document, $language);
        $this->getDocumentManager()->flush();

        $context = new Context();
        $context->setGroups(['defaultPage']);

        return $this->handleView($this->view($document)->setContext($context));
    }
1245190
public function viewAction(Request $request): Response
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);

        $this->isGrantedOr403($configuration, ResourceActions::SHOW);

        /** @var DefinedTranslationInterface|TemplateAwareInterface|ResourceInterface $resource */
        $resource = $this->findOr404($configuration);

        $this->eventDispatcher->dispatch(ResourceActions::SHOW, $configuration, $resource);

        $view = View::create($resource);

        if ($configuration->isHtmlRequest()) {
            $template = $resource->getTemplate();

            if ($template) {
                $tpl = $resource->getTemplateName();
                $options = $template->getOptions();
            } else {
                $tpl = $configuration->getTemplate(ResourceActions::SHOW.'.html');
                $options = [];
            }

            $this->addTranslations($resource);

            $view
                ->setTemplate($tpl)
                ->setTemplateVar($this->metadata->getName())
                ->setData(
                    [
                        'configuration' => $configuration,
                        'metadata' => $this->metadata,
                        'resource' => $resource,
                        'tpl' => ['options' => $options],
                        $this->metadata->getName() => $resource,
                    ]
                );
        }

        return $this->viewHandler->handle($configuration, $view);
    }
412110
public function submitAction(Request $request)
    {
        $name = $request->get('name');

        /** @var RequestConfiguration $configuration */
        $configuration = $this->requestConfigurationFactory->createSimple($request);
        $formConfiguration = $this->configurationFactory->create($name);

        $form = $this->createForm($formConfiguration->getForm());
        $form->handleRequest($request);

        $sent = false;
        if($form->isSubmitted()) {
            if($form->isValid()) {
                $model = $form->getData();
                $this->contactMailer->send($name, $model);
                $form = $this->createForm($formConfiguration->getForm());
                $sent = true;

                if($request->isXmlHttpRequest()) {
                    return new JsonResponse(array(
                        'message' => $this->translator->trans('contact.form.message.success', [], 'EnhavoContactBundle')
                    ));
                }
            } else {
                $errors = $this->formErrorResolver->getErrors($form);
                if($request->isXmlHttpRequest()) {
                    return new JsonResponse(array(
                        'message' => $errors[0]
                    ), 400);
                } else {
                    $this->addFlash('error', $errors);
                }
            }
        }

        $redirectRoute = null;
        if($request->get('_redirect_route')) {
            $redirectRoute = ($request->get('_redirect_route'));
        }

        $redirectParameters = [];
        if($request->get('_redirect_route_parameters')) {
            $redirectParameters = json_decode($request->get('_redirect_route_parameters'));
        }

        if($redirectRoute) {
            return $this->redirectToRoute($redirectRoute, $redirectParameters, 302);
        }

        $template = $configuration->getTemplate($formConfiguration->getPageTemplate());
        return $this->render($template, [
            'form' => $form->createView(),
            'name' => $name,
            'sent' => $sent
        ]);
    }
734296
public function changeAction(Request $request)
    {
        $regionManager = $this->get('compo_region.manager.region');

        $currentRegion = $request->request->get('current_region', $regionManager->getCurrentRegion());

        $regionManager->setCurrentRegion($currentRegion);

        return new JsonResponse($currentRegion);
    }
632456
public function loadAction(Request $request)
    {
        $repository = $this->get('phlexible_media_template.template_manager');

        $templateKey = $request->get('template_key');

        $template = $repository->find($templateKey);
        $parameters = $template->getParameters();

        if (isset($parameters['method'])) {
            $parameters['xmethod'] = $parameters['method'];
            unset($parameters['method']);
        }

        return new JsonResponse(['success' => true, 'data' => $parameters]);
    }
320
public function run(Request $request) {
		$id = $this->getParam('id');
		$sport = SportQuery::create()
			->leftJoinGroup()
			->leftJoinSkill()
			->findOneById($id);

		$pictures = PictureQuery::create()
			->useSkillQuery()
				->filterBySportId($id)
			->endUse()
			->count();

		$videos = VideoQuery::create()
			->useSkillQuery()
				->filterBySportId($id)
			->endUse()
			->count();

		$references = ReferenceQuery::create()
			->useSkillReferenceQuery()
				->useSkillQuery()
					->filterBySportId($id)
				->endUse()
			->endUse()
			->count();

		$statistics = [
			'skills' => $sport->countSkills(),
			'groups' => $sport->countGroups(),
			'pictures' => $pictures,
			'videos' => $videos,
			'references' => $references
		];

		return $this->responder->run($request, new Blank($statistics));
	}