protected function wrap($data, $with = [], $additional = [])
    {
        if ($data instanceof Collection) {
            $data = $data->all();
        }

        if ($this->haveDefaultWrapperAndDataIsUnwrapped($data)) {
            $data = [$this->wrapper() => $data];
        } elseif ($this->haveAdditionalInformationAndDataIsUnwrapped($data, $with, $additional)) {
            $data = [($this->wrapper() ?? 'data') => $data];
        }

        return array_merge_recursive($data, $with, $additional);
    }
protected function wrap($data, $with = [], $additional = [])
    {
        if ($data instanceof Collection) {
            $data = $data->all();
        }

        if ($this->haveDefaultWrapperAndDataIsUnwrapped($data)) {
            $data = [$this->wrapper() => $data];
        } elseif ($this->haveAdditionalInformationAndDataIsUnwrapped($data, $with, $additional)) {
            $data = [($this->wrapper() ?? 'data') => $data];
        }

        return array_merge_recursive($data, $with, $additional);
    }
protected function wrap ( $ data , $ with = [ ] , $ additional = [ ] ) { if ( $ data instanceof Collection ) { $ data = $ data -> all ( ) ; } if ( $ this -> haveDefaultWrapperAndDataIsUnwrapped ( $ data ) ) { $ data = [ $ this -> wrapper ( ) => $ data ] ; } elseif ( $ this -> haveAdditionalInformationAndDataIsUnwrapped ( $ data , $ with , $ additional ) ) { $ data = [ ( $ this -> wrapper ( ) ?? 'data' ) => $ data ] ; } return array_merge_recursive ( $ data , $ with , $ additional ) ; }
Wrap the given data if necessary.

@param  array  $data
@param  array  $with
@param  array  $additional
@return array
Wrap the given data if necessary .