protected  function response($message, $code = 200, $itemID = null, $redirectToView = '', $redirectUrl = '', $returnInputErrors = false, $errorsList = [], $noty = [])
    {
        // if we have input errors in the validator
        if($returnInputErrors) {
            return response()->json(
                array(
                    'code' =>           400,
                    'id'                => $itemID,
                    'errors'            => $errorsList,
                    'message'           => $message,
                    'redirectToView'    => $redirectToView,
                    'plugins'           => [],
                    'noty'              => $noty
                )
            );
        }
        // if there are no validation errors return normal errors or no errors if there are non
        return  [
            'code'          => $code,
            'id'            => $itemID,
            'errors'        => $errorsList,
            'message'       => $message,
            'redirectToView'=> $redirectToView,
            'redirectUrl'   => $redirectUrl,
            'plugins'       => [],
            'noty'          => $noty
        ];
    }
protected  function response($message, $code = 200, $itemID = null, $redirectToView = '', $redirectUrl = '', $returnInputErrors = false, $errorsList = [], $noty = [])
    {
        // if we have input errors in the validator
        if($returnInputErrors) {
            return response()->json(
                array(
                    'code' =>           400,
                    'id'                => $itemID,
                    'errors'            => $errorsList,
                    'message'           => $message,
                    'redirectToView'    => $redirectToView,
                    'plugins'           => [],
                    'noty'              => $noty
                )
            );
        }
        // if there are no validation errors return normal errors or no errors if there are non
        return  [
            'code'          => $code,
            'id'            => $itemID,
            'errors'        => $errorsList,
            'message'       => $message,
            'redirectToView'=> $redirectToView,
            'redirectUrl'   => $redirectUrl,
            'plugins'       => [],
            'noty'          => $noty
        ];
    }
protected function response ( $ message , $ code = 200 , $ itemID = null , $ redirectToView = '' , $ redirectUrl = '' , $ returnInputErrors = false , $ errorsList = [ ] , $ noty = [ ] ) { // if we have input errors in the validator if ( $ returnInputErrors ) { return response ( ) -> json ( array ( 'code' => 400 , 'id' => $ itemID , 'errors' => $ errorsList , 'message' => $ message , 'redirectToView' => $ redirectToView , 'plugins' => [ ] , 'noty' => $ noty ) ) ; } // if there are no validation errors return normal errors or no errors if there are non return [ 'code' => $ code , 'id' => $ itemID , 'errors' => $ errorsList , 'message' => $ message , 'redirectToView' => $ redirectToView , 'redirectUrl' => $ redirectUrl , 'plugins' => [ ] , 'noty' => $ noty ] ; }
Handle ajax responses (mainly used by view vue js.

@param  integer $code              HTTP response code
@param  string  $message           The message to be shown along the error
@param  int     $itemID            The ID of the editing item
@param  string  $redirectToView    The view to be redirected to if ajax response is successful
@param  string  $redirectUrl       The URL to be redirected to if ajax response is successful
@param  boolean $returnInputErrors If true, it handle input errors
@param  array   $errorsList        The list of errors in array, ex. ["field_name" => array("Error 1","Error 2")]
@param  array   $noty              Custom notifications list
@return array
Handle ajax responses ( mainly used by view vue js .