protected function respondTransformer($data, $code, TransformerAbstract $transformer, array $headers = [])
    {
        if ($data === null) { // If we have empty result
            return $this->respond(
                [
                    'data' => []
                ],
                $code,
                $headers
            );
        }

        if ($data instanceof LengthAwarePaginator) { // If we have paginated collection
            $resource = new Collection($data->items(), $transformer);
            return $this->respond(
                [
                    'meta'   => [
                        'total'       => $data->total(),
                        'perPage'     => $data->perPage(),
                        'currentPage' => $data->currentPage(),
                        'lastPage'    => $data->lastPage(),
                        'link'        => \URL::current()
                    ],
                    'params' => $this->processor->getProcessedFields(),
                    'data'   => $this->getSerializer()->createData($resource)->toArray()
                ],
                $code,
                $headers
            );
        } elseif ($data instanceof LaravelCollection) { // Collection without pagination
            $resource = new Collection($data, $transformer);
            return $this->respond(
                [
                    'data' => $this->getSerializer()->createData($resource)->toArray()
                ],
                $code,
                $headers
            );
        } else { // Single entity
            $resource = new Item($data, $transformer);
            return $this->respond(
                $this->getSerializer()->createData($resource)->toArray(),
                $code,
                $headers
            );
        }
    }