Handle current request and start form data validation.

@param Request $request

@throws \Illuminate\Validation\ValidationException

@return $this
502486
public function handleRequest(Request $request): FormInterface
    {
        $fields = $this->repository->all();

        $this->validator = $this->validation->make(
            $request->all(),
            $this->getFormRules($fields),
            $this->getFormMessages($fields),
            $this->getFormPlaceholders($fields)
        );

        $data = $this->validator->valid();

        // Attach the errors message bag to each field.
        // Set each field value.
        // Update the DTO instance with form data if defined.
        array_walk($fields, function ($field) use ($data) {
            /** @var $field BaseType */
            $field->setErrorMessageBag($this->errors());

            // Set the field value. Each field has its own data transformer so when we
            // call the field getValue() method later on, we're sure to fetch a correct
            // formatted value.
            $field->setValue(Arr::get($data, $field->getName()));

            // DTO
            if (! is_null($this->dataClass) && is_object($this->dataClass) && $field->getOption('mapped')) {
                $this->dataMapper->mapFromFieldToObject($field, $this->dataClass);
            }

            // By default, if the form is not valid, we keep populating fields values.
            // In the case of a valid form, by default, values are flushed except if
            // the "flush" option for the form has been set to true.
            if ($this->validator->fails()) {
                if ($field->error()) {
                    // Add invalid CSS classes.
                    $field->addAttribute('class', 'is-invalid');
                } else {
                    // Add valid CSS classes and validate the field.
                    $field->addAttribute('class', 'is-valid');
                }
            } else {
                // Validation is successful, we can flush fields value at output.
                if ($this->getOption('flush', false)) {
                    $field['flush'] = true;
                }
            }
        });

        return $this;
    }
673868
public
    function store(Validator $request)
    {
        $init = new InitData($request);
        Model::quickSave($init->getDataForCreate());
        flash()->success('Your Item Created');
        return redirect()->to("menus/");
    }
1108249
public function setRequest(Request $request)
    {
        $this->request = $request;
        $this->context->registerInstance($request);
    }
982969
public
    function store(Validator $request)
    {
        $init = new InitData($request);
        Model::quickSave($init->getDataForCreate());
        flash()->success('Your Item Created');
        return redirect()->to(self::getScope().'/'.self::getModule($this));
    }
1229018
public function handle(Request $request)
    {
        try {
            $this->loadConfiguration();

            // Now that Configuration is loaded let's resolve controller
            // for given request.
            $calls = $this->resolveController($request);
            $controller = $calls['controller'];
            $callable   = $calls['callable'];

            // Resolve arguments before calling controller
            $res = $controller->$callable();

            // Check if controller returned Response
            // and if so let's use it as our response
            if (is_a($res, 'Symfony\Component\HttpFoundation\Response')) {
                $this->response = $res;
            }

        } catch (\Exception $e) {
            $error = new \StdClass;
            $error->message = $e->getMessage();
            $error->code    = $e->getCode();
            $this->response->setStatusCode($e->getCode());
            $this->response->setContent(json_encode($error));
            $this->response->headers->set('Content-Type', 'application/json');
        }

        // Send response
        if ($request->getRequestFormat() == 'json') {
            $this->response->headers->set('Content-Type', 'application/json');
        }

        $this->response->send();

    }
470519
public function handle(FormRequest $request)
    {
        try{

            $form = $this->resolve();

            // validate request
            $request->validate($form->fields);

            $form->request = $request;

            // fire callbacks
            $this->kernel->fireEvent($form);

            // return success
            return true;

        } catch(FormException $e){

            // form validation errors
            $this->kernel->setErrors($this->form, $e->getErrors()->messages());

            // return failure
            return false;

        } catch(QueryException $e){

            // database errors
            //todo log exception
            throw new HttpException(500, $e->getMessage());
            //throw new HttpException(500, "Database error.");

        } catch(\Exception $e){

            // general exceptions
            //todo log exception
            throw new HttpException(500, $e->getMessage());

        }
    }
1211036
public function reset(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'token'    => 'required',
            'email'    => 'required|email',
            'password' => 'required|confirmed|min:6',
        ]);

        if ($validator->fails()) {
            return response()->json($validator->errors(), 400);
        }

        $credentials = $request->only('email', 'password', 'password_confirmation', 'token');

        $response = Password::reset($credentials, function ($user, $password) {

            $this->resetPassword($user, $password); // @codeCoverageIgnore
        });

        switch ($response) {
            case Password::PASSWORD_RESET:
                return response()->json(null, 200);

            default:
                return response()->json(null, 400);
        }
    }
1374959
public function write($request)
    {
        if ($this->isComplete) {
            throw new ValidationException("Cannot call write() after streaming call is complete.");
        }
        if ($this->writesClosed) {
            throw new ValidationException("Cannot call write() after calling closeWrite().");
        }
        $this->call->write($request);
    }
512550
protected function setupRouter(Request $request)
    {
        if ($request instanceof Request\Web) {
            $router = $this->getRouter();
            if (
                $router instanceof Router\RouterCuInterface
                && $router->isRequestedUrlClean($request))
            {
                $router->enableCleanUrls();
            }
        }

        return $this;
    }
835431
protected function preparePaging(Request $request)
    {
        self::$countBeforePaging = $this->query->count();
        $this->query->limit($request->getLength());
        $this->query->offset($request->getStart());
    }
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);
    }
501662
protected function validateRequest(Request $request)
    {
        $validationErrors = array();

        if (strlen($request->getApiMethod()) == 0)
        {
            $validationErrors[] = 'Request api method is empty';
        }

        if (strlen($request->getEndPoint()) == 0 && strlen($request->getEndPointGroup()) === 0)
        {
            $validationErrors[] = 'Request end point is empty and request end point group is empty. Set one of them.';
        }

        if (strlen($request->getEndPoint()) > 0 && strlen($request->getEndPointGroup()) > 0)
        {
            $validationErrors[] = 'Request end point was set and request end point group was set. Set only one of them.';
        }

        if (count($request->getRequestFields()) === 0)
        {
            $validationErrors[] = 'Request data is empty';
        }

        if (!Validator::validateByRule($request->getGatewayUrl(), Validator::URL, false))
        {
            $validationErrors[] = 'Gateway url does not valid in Request';
        }

        if (!empty($validationErrors))
        {
            throw new ValidationException("Some Request fields are invalid:\n" .
                                          implode(";\n", $validationErrors));
        }
    }
495899
public function validateRequest(Request $request): ResponseInterface
    {
        $case = $this->makeCase($request);

        $caseId = $this->getApiClient()->createCase($case);

        if (!$caseId) {
            throw new RequestException(
                'Could not create Signifyd Case: '
                . $this->getApiClient()->getLastErrorMessage()
            );
        }

        return new CaseIdResponse($caseId);
    }
1344116
public function handle(Request $request)
    {
        foreach ($this->staticContentPatterns as $ptn) {
            if (preg_match($ptn, $request->getRequestUri(), $m)) {
                $path = urldecode(parse_url($m[1], PHP_URL_PATH));
                if (!is_file($this->webDir . $path)) {
                    return $this->createDefaultNotFoundResponse($path);
                }
            }
        }
        return null;
    }
359115
public function validate(Request $request)
    {
        return ! \is_null($this->domain) && $request->getHost() === $this->getStrippedDomain();
    }
563118
public function validate(Request $request, array $rules = [], array $messages = [], array $customAttributes = [])
    {
        $rules = array_merge_recursive(config('forum.validation.rules'), $rules);

        $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
    }
879455
public function run(Request $request)
    {
        $this->container = $this->container ?: Application::getInstance();
        $this->container->set(Request::class, $request);

        // Check and run controller
        if ($this->isControllerAction()) {
            return $this->runController();
        }

        return $this->runCallable();
    }