src/Exceptions/ValidationException.php
public function getResponse($route, $parameters, $config = [])
    {
        // Copy standard response.
        $response = self::$response;

        // Fill the response.
        array_set($response, 'is_error', true);
        array_set($response, 'message', $this->getMessage());
        array_set($response, 'fields', array_keys($this->validator->errors()->messages()));
        array_set($response, 'feedback', $this->validator->errors()->all());
        array_set($response, 'errors', $this->validator->errors());

        if (array_has($config, 'feedback.html')) {
            array_set(
                $response,
                'feedback',
                '<ul><li>'.implode('</li><li>', array_get($response, 'feedback')).'</li></ul>'
            );
        }

        // JSON response required.
        if (request()->ajax() || request()->wantsJson()) {
            return response()
                ->json($response, 422);
        }

        // Redirect response, flash to session.
        session()->flash('is_error', true);
        session()->flash('message', array_get($response, 'message', ''));
        session()->flash('feedback', array_get($response, 'feedback', ''));
        session()->flash('fields', array_get($response, 'fields', []));

        // Redirect to provided route.
        return redirect()
            ->route($route, $parameters)
            ->withErrors($this->getValidator())
            ->withInput();
    }
public function getResponse($route, $parameters, $config = [])
    {
        // Copy standard response.
        $response = self::$response;

        // Fill the response.
        array_set($response, 'is_error', true);
        array_set($response, 'message', $this->getMessage());
        array_set($response, 'fields', array_keys($this->validator->errors()->messages()));
        array_set($response, 'feedback', $this->validator->errors()->all());
        array_set($response, 'errors', $this->validator->errors());

        if (array_has($config, 'feedback.html')) {
            array_set(
                $response,
                'feedback',
                '<ul><li>'.implode('</li><li>', array_get($response, 'feedback')).'</li></ul>'
            );
        }

        // JSON response required.
        if (request()->ajax() || request()->wantsJson()) {
            return response()
                ->json($response, 422);
        }

        // Redirect response, flash to session.
        session()->flash('is_error', true);
        session()->flash('message', array_get($response, 'message', ''));
        session()->flash('feedback', array_get($response, 'feedback', ''));
        session()->flash('fields', array_get($response, 'fields', []));

        // Redirect to provided route.
        return redirect()
            ->route($route, $parameters)
            ->withErrors($this->getValidator())
            ->withInput();
    }
public function getResponse ( $ route , $ parameters , $ config = [ ] ) { // Copy standard response. $ response = self :: $ response ; // Fill the response. array_set ( $ response , 'is_error' , true ) ; array_set ( $ response , 'message' , $ this -> getMessage ( ) ) ; array_set ( $ response , 'fields' , array_keys ( $ this -> validator -> errors ( ) -> messages ( ) ) ) ; array_set ( $ response , 'feedback' , $ this -> validator -> errors ( ) -> all ( ) ) ; array_set ( $ response , 'errors' , $ this -> validator -> errors ( ) ) ; if ( array_has ( $ config , 'feedback.html' ) ) { array_set ( $ response , 'feedback' , '<ul><li>' . implode ( '</li><li>' , array_get ( $ response , 'feedback' ) ) . '</li></ul>' ) ; } // JSON response required. if ( request ( ) -> ajax ( ) || request ( ) -> wantsJson ( ) ) { return response ( ) -> json ( $ response , 422 ) ; } // Redirect response, flash to session. session ( ) -> flash ( 'is_error' , true ) ; session ( ) -> flash ( 'message' , array_get ( $ response , 'message' , '' ) ) ; session ( ) -> flash ( 'feedback' , array_get ( $ response , 'feedback' , '' ) ) ; session ( ) -> flash ( 'fields' , array_get ( $ response , 'fields' , [ ] ) ) ; // Redirect to provided route. return redirect ( ) -> route ( $ route , $ parameters ) -> withErrors ( $ this -> getValidator ( ) ) -> withInput ( ) ; }
Get a response to return.

@return string|array
Get a response to return .