src/Http/SuccessResponseBuilder.php
public function transform($data = null, $transformer = null, string $resourceKey = null):SuccessResponseBuilder
    {
        $resource = $this->resourceFactory->make($data);

        if (! is_null($resource->getData())) {
            $model = $this->resolveModel($resource->getData());
            $transformer = $this->resolveTransformer($model, $transformer);
            $resourceKey = $this->resolveResourceKey($model, $resourceKey);
        }

        if ($transformer instanceof Transformer) {
            $this->include($relations = $this->resolveNestedRelations($resource->getData()));

            if ($transformer->allRelationsAllowed()) {
                $transformer->setRelations($relations);
            }
        }

        $this->resource = $resource->setTransformer($transformer)->setResourceKey($resourceKey);

        return $this;
    }
public function transform($data = null, $transformer = null, string $resourceKey = null):SuccessResponseBuilder
    {
        $resource = $this->resourceFactory->make($data);

        if (! is_null($resource->getData())) {
            $model = $this->resolveModel($resource->getData());
            $transformer = $this->resolveTransformer($model, $transformer);
            $resourceKey = $this->resolveResourceKey($model, $resourceKey);
        }

        if ($transformer instanceof Transformer) {
            $this->include($relations = $this->resolveNestedRelations($resource->getData()));

            if ($transformer->allRelationsAllowed()) {
                $transformer->setRelations($relations);
            }
        }

        $this->resource = $resource->setTransformer($transformer)->setResourceKey($resourceKey);

        return $this;
    }
public function transform ( $ data = null , $ transformer = null , string $ resourceKey = null ) : SuccessResponseBuilder { $ resource = $ this -> resourceFactory -> make ( $ data ) ; if ( ! is_null ( $ resource -> getData ( ) ) ) { $ model = $ this -> resolveModel ( $ resource -> getData ( ) ) ; $ transformer = $ this -> resolveTransformer ( $ model , $ transformer ) ; $ resourceKey = $ this -> resolveResourceKey ( $ model , $ resourceKey ) ; } if ( $ transformer instanceof Transformer ) { $ this -> include ( $ relations = $ this -> resolveNestedRelations ( $ resource -> getData ( ) ) ) ; if ( $ transformer -> allRelationsAllowed ( ) ) { $ transformer -> setRelations ( $ relations ) ; } } $ this -> resource = $ resource -> setTransformer ( $ transformer ) -> setResourceKey ( $ resourceKey ) ; return $ this ; }
Set the transformation data. This will set a new resource instance on the response
builder depending on what type of data is provided.

@param  mixed|null           $data
@param  callable|string|null $transformer
@param  string|null          $resourceKey
@return self
Set the transformation data . This will set a new resource instance on the response builder depending on what type of data is provided .