public function make($data, $code, $overwrite = false)
    {
        // Status returned.
        $status = (preg_match('/^(1|2|3)/', $code)) ? 'success' : 'error';

        // Change object to array.
        if (is_object($data))
        {
            $data = $data->toArray();
        }

        // Data as a string.
        if (is_string($data))
        {
            $data = array('message' => $data);
        }

        // Overwrite response format.
        if ($overwrite === true)
        {
            $response = $data;
        }
        else
        {
            $message = $this->statuses[$code];

            // Custom return message.
            if (isset($data['message']))
            {
                $message = $data['message'];

                unset($data['message']);
            }

            // Available data response.
            $response = array(
                'status'     => $status,
                'code'       => $code,
                'message'    => $message,
                'data'       => $data,
                'pagination' => null
            );

            // Merge if data has anything else.
            if (isset($data['data']))
            {
                $response = array_merge($response, $data);
            }

            // Remove empty array.
            $response = array_filter($response, function($value)
            {
                return ! is_null($value);
            });

            // Remove empty data.
            if ($this->config['removeEmptyData'] && empty($response['data']))
            {
                unset($response['data']);
            }
        }

        // Header response.
        $header = ($this->config['httpResponse']) ? $code : 200;

        return Response::make($response, $header);
    }
public function make($data, $code, $overwrite = false)
    {
        // Status returned.
        $status = (preg_match('/^(1|2|3)/', $code)) ? 'success' : 'error';

        // Change object to array.
        if (is_object($data))
        {
            $data = $data->toArray();
        }

        // Data as a string.
        if (is_string($data))
        {
            $data = array('message' => $data);
        }

        // Overwrite response format.
        if ($overwrite === true)
        {
            $response = $data;
        }
        else
        {
            $message = $this->statuses[$code];

            // Custom return message.
            if (isset($data['message']))
            {
                $message = $data['message'];

                unset($data['message']);
            }

            // Available data response.
            $response = array(
                'status'     => $status,
                'code'       => $code,
                'message'    => $message,
                'data'       => $data,
                'pagination' => null
            );

            // Merge if data has anything else.
            if (isset($data['data']))
            {
                $response = array_merge($response, $data);
            }

            // Remove empty array.
            $response = array_filter($response, function($value)
            {
                return ! is_null($value);
            });

            // Remove empty data.
            if ($this->config['removeEmptyData'] && empty($response['data']))
            {
                unset($response['data']);
            }
        }

        // Header response.
        $header = ($this->config['httpResponse']) ? $code : 200;

        return Response::make($response, $header);
    }
public function make ( $ data , $ code , $ overwrite = false ) { // Status returned. $ status = ( preg_match ( '/^(1|2|3)/' , $ code ) ) ? 'success' : 'error' ; // Change object to array. if ( is_object ( $ data ) ) { $ data = $ data -> toArray ( ) ; } // Data as a string. if ( is_string ( $ data ) ) { $ data = array ( 'message' => $ data ) ; } // Overwrite response format. if ( $ overwrite === true ) { $ response = $ data ; } else { $ message = $ this -> statuses [ $ code ] ; // Custom return message. if ( isset ( $ data [ 'message' ] ) ) { $ message = $ data [ 'message' ] ; unset ( $ data [ 'message' ] ) ; } // Available data response. $ response = array ( 'status' => $ status , 'code' => $ code , 'message' => $ message , 'data' => $ data , 'pagination' => null ) ; // Merge if data has anything else. if ( isset ( $ data [ 'data' ] ) ) { $ response = array_merge ( $ response , $ data ) ; } // Remove empty array. $ response = array_filter ( $ response , function ( $ value ) { return ! is_null ( $ value ) ; } ) ; // Remove empty data. if ( $ this -> config [ 'removeEmptyData' ] && empty ( $ response [ 'data' ] ) ) { unset ( $ response [ 'data' ] ) ; } } // Header response. $ header = ( $ this -> config [ 'httpResponse' ] ) ? $ code : 200 ; return Response :: make ( $ response , $ header ) ; }
Make json data format.

@param  mixed   $data
@param  integer $code
@param  boolean $overwrite
@return string
Make json data format .