public function response()
    {
        if ($this->isAjax()) {
            if ($this->errors) {
                return $this->responseJson([
                    'errors' => $this->errors,
                ]);
            } else {
                return $this->responseJson([
                    'message'     => $this->message,
                    'messageType' => $this->messageType,
                    'redirect'    => $this->redirect,
                ]);
            }
        } else {
            if ($this->errors) {
                return redirect($this->redirect)
                    ->withInput()
                    ->withErrors($this->errors);
            } else {
                return redirect($this->redirect)
                    ->withInput()
                    ->with('message', $this->message)
                    ->with('messageType', $this->messageType);
            }
        }
    }
public function response()
    {
        if ($this->isAjax()) {
            if ($this->errors) {
                return $this->responseJson([
                    'errors' => $this->errors,
                ]);
            } else {
                return $this->responseJson([
                    'message'     => $this->message,
                    'messageType' => $this->messageType,
                    'redirect'    => $this->redirect,
                ]);
            }
        } else {
            if ($this->errors) {
                return redirect($this->redirect)
                    ->withInput()
                    ->withErrors($this->errors);
            } else {
                return redirect($this->redirect)
                    ->withInput()
                    ->with('message', $this->message)
                    ->with('messageType', $this->messageType);
            }
        }
    }
public function response ( ) { if ( $ this -> isAjax ( ) ) { if ( $ this -> errors ) { return $ this -> responseJson ( [ 'errors' => $ this -> errors , ] ) ; } else { return $ this -> responseJson ( [ 'message' => $ this -> message , 'messageType' => $ this -> messageType , 'redirect' => $ this -> redirect , ] ) ; } } else { if ( $ this -> errors ) { return redirect ( $ this -> redirect ) -> withInput ( ) -> withErrors ( $ this -> errors ) ; } else { return redirect ( $ this -> redirect ) -> withInput ( ) -> with ( 'message' , $ this -> message ) -> with ( 'messageType' , $ this -> messageType ) ; } } }
Returns the proper response to user. If the request was made from ajax, then an json response is sent.
If a request is a typical request without ajax, a user is sent a redirect with session flash messages.

@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
Returns the proper response to user . If the request was made from ajax then an json response is sent . If a request is a typical request without ajax a user is sent a redirect with session flash messages .