Загружаем изображения для виджета.

@param Request $request

@return AttachImagesToWidgetResponseContract
771629
public function attachImagesToWidget(Request $request): AttachImagesToWidgetResponseContract
    {
        $widgetID = (int) $request->get('widgetID');
        $widgetType = $request->get('material_type');

        $this->services['widgets']->attachImagesToWidget($widgetID, $widgetType);

        return app()->makeWith('InetStudio\Widgets\Contracts\Http\Responses\Back\GalleryWidgets\AttachImagesToWidgetResponseContract', [
            'result' => [
                'success' => true,
            ],
        ]);
    }
201558
public function setRequest(Request $request)
    {
        $context = (new RequestContext())->fromRequest($request);

        $this->cachedRoot = null;
        $this->cachedSchema = null;
        return $this->setContext($context);
    }
583360
public function cssMapAction(Request $request)
    {
        $baseUrlContentFilter = $this->get('phlexible_gui.asset.base_url_content_filter');
        $baseUrlContentFilter->setBasePath($request->getBasePath());
        $baseUrlContentFilter->setBaseUrl($request->getBaseUrl());

        $cssBuilder = $this->get('phlexible_gui.asset.css_builder');

        $asset = $cssBuilder->build();

        return new BinaryFileResponse($asset->getMapAsset(), 200, array('Content-Type' => 'application/json;charset=UTF-8'));
    }
1271289
public function bindRequest(Request $request)
    {
        $query = $request->query;
        $session = $request->getSession();

        $adminListName = 'listconfig_'.$request->get('_route');

        $this->page = $request->query->getInt('page', 1);
        // Allow alphanumeric, _ & . in order by parameter!
        $this->orderBy = preg_replace('/[^[a-zA-Z0-9\_\.]]/', '', $request->query->get('orderBy', ''));
        $this->orderDirection = $request->query->getAlpha('orderDirection', '');

        // there is a session and the filter param is not set
        if ($session->has($adminListName) && !$query->has('filter')) {
            $adminListSessionData = $request->getSession()->get($adminListName);
            if (!$query->has('page')) {
                $this->page = $adminListSessionData['page'];
            }

            if (!$query->has('orderBy')) {
                $this->orderBy = $adminListSessionData['orderBy'];
            }

            if (!$query->has('orderDirection')) {
                $this->orderDirection = $adminListSessionData['orderDirection'];
            }
        }

        // save current parameters
        $session->set(
            $adminListName,
            array(
                'page' => $this->page,
                'orderBy' => $this->orderBy,
                'orderDirection' => $this->orderDirection,
            )
        );

        $this->getFilterBuilder()->bindRequest($request);
    }
959717
public function uploadAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();

        $uploadFile = $em->getRepository('CompoImportBundle:UploadFile')->find($request->get('import_id'));

        $countImport = $em->getRepository('CompoImportBundle:ImportLog')->count([
            'uploadFile' => $uploadFile->getId(),
        ]);

        $data = $em->getRepository('CompoImportBundle:ImportLog')->pagerfanta($request);

        $paginator = $this->get('knp_paginator');

        /** @var SlidingPagination $pagination */
        $pagination = $paginator->paginate(
            $data,
            $request->query->getInt('page', 1),
            100
        );

        $pagination->setCustomParameters(['type' => $request->get('type', 'all')]);

        $pagination->setParam('type', $request->get('type', 'all'));

        $stats = [
            0 => [
                'status' => 0,
                'count' => 0,
            ],
            1 => [
                'status' => 1,
                'count' => 0,
            ],
            2 => [
                'status' => 2,
                'count' => 0,
            ],
            3 => [
                'status' => 3,
                'count' => 0,
            ],
        ];

        foreach ($stats as $statKey => $stat) {
            $stats[$statKey]['count'] = $em->getRepository('CompoImportBundle:ImportLog')->count([
                'uploadFile' => $uploadFile->getId(),
                'status' => $stat['status'],
            ]);
        }

        return $this->renderWithExtraParams('@CompoImport/Default/upload.html.twig', [
            'uploadFile' => $uploadFile,
            'paginator' => $pagination,
            'action' => 'upload',
            'admin' => $this->admin,
            'stats' => $stats,

            'countImport' => $countImport,
            'base_template' => $this->getBaseTemplate(),
        ]);
    }
1154036
public function post(Request $request)
	{
		$this->validate($request, [
            'file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:4096',
        ]);

		$fileName = basename($request->file->getClientOriginalName(), '.' . $request->file->getClientOriginalExtension());
		$fileExtension = $request->file->getClientOriginalExtension();
		$postName = $this->sanitizeUrl($fileName);
		$mime = $request->file->getMimeType();

		$postmeta = NikuPostmeta::where([
			['meta_key', '=', 'attachment_url'],
			['meta_value', 'LIKE', '/uploads/images/' . $fileName . '%']
		])->get();

		if($postmeta->count() != 0){
			$count = $postmeta->count() + 1;
			$fileCount = '-' . $count;
		} else {
			$fileCount = '';
		}

		$postName = $postName . $fileCount;
		$fileName = $fileName . $fileCount . '.' . $fileExtension;

		$post = new NikuPosts;
		$post->post_title = $fileName;
		$post->post_name = $postName;
		$post->post_type = 'attachment';
		$post->post_mime_type = $mime;
		$post->status = 'inherit';
		if(Auth::check()){
			$post->post_author = Auth::user()->id;
		} else {
			$post->post_author = '0';
		}
		$post->save();

		$postmeta = new NikuPostmeta;
		$postmeta->post_id = $post->id;
		$postmeta->meta_key = 'attachment_url';
		$postmeta->meta_value = '/uploads/images/' . $fileName;
		$postmeta->save();

        $request->file->move(public_path('uploads/images'), $fileName);

        $postObject = collect([
        	'status' => 0,
        	'postmeta' => [
        		0 => [
        			'meta_value' => $postmeta->meta_value,
        		]
        	],
        	'id' => $postmeta->post_id
        ]);

        return response()->json([
		    'object' => $postObject
		]);
	}
1188769
public function insertCustom(Request $request)
    {
        $validation = Validator::make($request->all(), [
            'name'  => 'required|unique:menus,name',
            'title' => 'required'
        ]);
        if ($validation->fails()) {
            return redirect()->back()->withInput()->withErrors($validation);
        }
        // Create controller
        $controllerBuilder = new ControllerBuilder();
        $controllerBuilder->buildCustom($request->name);

        // Create views
        $viewsBuilder = new ViewsBuilder();
        $viewsBuilder->buildCustom($request->name);

        $menu = Menu::create([
            'position'  => 0,
            'menu_type' => 3,
            'icon'      => $request->icon != '' ? $request->icon : 'fa-database',
            'name'      => $request->name,
            'title'     => $request->title,
            'parent_id' => $request->parent_id ?: null,
        ]);
        $menu->roles()->sync($request->input('roles', []));

        return redirect()->route('menu');
    }
912616
public function newAction(Request $request)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_CREATE);

        /** @var PluginConfigurator $pluginConfigurator */
        $pluginConfigurator = $configuratorFactory->getConfigurator(PluginConfigurator::class);
        $template = $pluginConfigurator->isBulkInsertEnabled() ? $crudConfigurator->getTemplate()->getBulkCreate() : $crudConfigurator->getTemplate()->getCreate();

        $modelClass = $crudConfigurator->getCrud()->getModelClass();
        $model = new $modelClass();
        $form = $crudConfigurator->getForm($model);

        return $this->createOrUpdate($request, $model, $form, Constants::ACTION_CREATE, $template);
    }
56582
public function upload(Request $request)
    {
        try {
            $realPath = Storage::disk($this->filesystem)->getDriver()->getAdapter()->getPathPrefix();

            $allowedImageMimeTypes = [
                'image/jpeg',
                'image/png',
                'image/gif',
                'image/bmp',
                'image/svg+xml',
            ];

            if (in_array($request->file->getMimeType(), $allowedImageMimeTypes)) {
                $file = $request->file->store($request->upload_path, $this->filesystem);

                $image = Image::make($realPath.$file);

                if ($request->file->getClientOriginalExtension() == 'gif') {
                    copy($request->file->getRealPath(), $realPath.$file);
                } else {
                    $image->orientate()->save($realPath.$file);
                }
            } else {
                $file = $request->file->move($realPath, $request->file->getClientOriginalName());
            }

            $success = true;
            $message = __('admin.media.success_uploaded_file');
            $path = preg_replace('/^public\//', '', $file);
        } catch (Exception $e) {
            $success = false;
            $message = $e->getMessage();
            $path = '';
        }

        return response()->json(compact('success', 'message', 'path'));
    }
116242
public function upload(Request $request)
    {
        $attachment = [];
        foreach ($request->allFiles() as $files) {
            $files = Arr::wrap($files);

            foreach ($files as $file) {
                $attachment[] = $this->createModel($file, $request);
            }
        }

        $attachment = count($attachment) > 1 ? $attachment : reset($attachment);

        return response()->json($attachment);
    }
1096477
public function imageAction(Request $request)
    {
        $response = $this->getCacheTimeKeeper()->getResponse();
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        return $this->render('AnimeDbAppBundle:Form:image.html.twig', [
            'form' => $this->createForm(new UploadImage())->createView(),
            'change' => (bool) $request->get('change', false),
        ], $response);
    }
116357
public function addToCampaignForm($request)
    {
        // Get ID either from posted back value, or url parameter
        $id = $request->param('ID') ?: $request->postVar('ID');
        return $this->getAddToCampaignForm($id);
    }
574621
public function via(RequestContract $request): RequestContract
    {
        $request->setClient($this);
        $request->onTimeZone($this->requestHeaderTimezoneCode);

        return $request;
    }
1258894
public function postImport(Request $request)
    {

        $form = FormBuilder::create($this->import_form, [
            'model' => $this->model
        ]);


        if ($form->hasError())
        {
            return $form->validateAndRedirectBack();
        }


        $file = $request->get('file');
        $file = urldecode($file);
        if (!app('files')->exists($file))
        {
            return redirect()->back()->with(Message::WARNING, [trans('expendable::errors.file_not_found')]);
        }
        $file = str_replace(storage_path('app/'), '', $file);

        (new BaseImport($this->model))->importFromFile($file);

        return redirect()->back()->with(Message::MESSAGE, [trans('expendable::success.imported')]);

    }
60613
public function addToRequest(Request $request)
    {
        foreach ($this->cookies as $cookie) {
            $request = $request->withCookie($cookie->getName(), $cookie->getValue());
        }

        return $request;
    }
430926
protected function sendRequest(RequestContract $request): ResponseContract
    {
        $this->app->instance('request', $this->bindRequestMatcher($request));

        Facade::clearResolvedInstance('request');

        return (new Pipeline($this->app))
            ->send($request)
            ->through(array_merge($this->middleware, $request->matcher()->getCallerMiddleware()))
            ->then(function (RequestContract $request) {
                return $this->toResponse(
                    $this->app->call($request->matcher()->getCallerUses())
                );
            });
    }
1050815
public function newAction(Request $request)
    {
        $slider = new Slider();
        $form = $this->createForm('CoreExtraBundle\Form\SliderType', $slider,  array('uploadDir'=> 'uploads/images/slider' ));
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            
            //clean image form
            $this->get('core_manager')->cleanImageForm($request->files->get('slider'), $slider);
            
            $em->persist($slider);
            $em->flush();
            
            $this->get('session')->getFlashBag()->add('success', 'slider.created');

            return $this->redirectToRoute('coreextra_slider_index');
        }

        return array(
            'entity' => $slider,
            'form' => $form->createView(),
        );
    }