public function transform()
    {
        $object = $this->resource;

        $data = $object instanceof Collection || $object instanceof AbstractPaginator
            ? $object->map([$this, 'transformResource'])->toArray()
            : $this->transformResource($object);

        if ($object instanceof AbstractPaginator) {
            $this->withMeta(array_merge(
                $this->getExtra('meta', []), Arr::except($object->toArray(), ['data'])
            ));
        }

        $data = array_filter(compact('data') + $this->extras);
        ksort($data);

        return $data;
    }