public function transform($response, $transformer, Binding $binding, Request $request)
    {
        $this->parseFractalIncludes($request);

        $resource = $this->createResource($response, $transformer, $parameters = $binding->getParameters());

        // If the response is a paginator then we'll create a new paginator
        // adapter for Laravel and set the paginator instance on our
        // collection resource.
        if ($response instanceof IlluminatePaginator) {
            $paginator = $this->createPaginatorAdapter($response);

            $resource->setPaginator($paginator);
        }

        if ($this->shouldEagerLoad($response)) {
            $eagerLoads = $this->mergeEagerLoads($transformer, $this->fractal->getRequestedIncludes());

            if ($transformer instanceof TransformerAbstract) {
                // Only eager load the items in available includes
                $eagerLoads = \array_intersect($eagerLoads, $transformer->getAvailableIncludes());
            }

            $response->load($eagerLoads);
        }

        foreach ($binding->getMeta() as $key => $value) {
            $resource->setMetaValue($key, $value);
        }

        $binding->fireCallback($resource, $this->fractal);

        $identifier = $parameters['identifier'] ?? null;

        return $this->fractal->createData($resource, $identifier)->toArray();
    }
public function transform($response, $transformer, Binding $binding, Request $request)
    {
        $this->parseFractalIncludes($request);

        $resource = $this->createResource($response, $transformer, $parameters = $binding->getParameters());

        // If the response is a paginator then we'll create a new paginator
        // adapter for Laravel and set the paginator instance on our
        // collection resource.
        if ($response instanceof IlluminatePaginator) {
            $paginator = $this->createPaginatorAdapter($response);

            $resource->setPaginator($paginator);
        }

        if ($this->shouldEagerLoad($response)) {
            $eagerLoads = $this->mergeEagerLoads($transformer, $this->fractal->getRequestedIncludes());

            if ($transformer instanceof TransformerAbstract) {
                // Only eager load the items in available includes
                $eagerLoads = \array_intersect($eagerLoads, $transformer->getAvailableIncludes());
            }

            $response->load($eagerLoads);
        }

        foreach ($binding->getMeta() as $key => $value) {
            $resource->setMetaValue($key, $value);
        }

        $binding->fireCallback($resource, $this->fractal);

        $identifier = $parameters['identifier'] ?? null;

        return $this->fractal->createData($resource, $identifier)->toArray();
    }
public function transform ( $ response , $ transformer , Binding $ binding , Request $ request ) { $ this -> parseFractalIncludes ( $ request ) ; $ resource = $ this -> createResource ( $ response , $ transformer , $ parameters = $ binding -> getParameters ( ) ) ; // If the response is a paginator then we'll create a new paginator // adapter for Laravel and set the paginator instance on our // collection resource. if ( $ response instanceof IlluminatePaginator ) { $ paginator = $ this -> createPaginatorAdapter ( $ response ) ; $ resource -> setPaginator ( $ paginator ) ; } if ( $ this -> shouldEagerLoad ( $ response ) ) { $ eagerLoads = $ this -> mergeEagerLoads ( $ transformer , $ this -> fractal -> getRequestedIncludes ( ) ) ; if ( $ transformer instanceof TransformerAbstract ) { // Only eager load the items in available includes $ eagerLoads = \ array_intersect ( $ eagerLoads , $ transformer -> getAvailableIncludes ( ) ) ; } $ response -> load ( $ eagerLoads ) ; } foreach ( $ binding -> getMeta ( ) as $ key => $ value ) { $ resource -> setMetaValue ( $ key , $ value ) ; } $ binding -> fireCallback ( $ resource , $ this -> fractal ) ; $ identifier = $ parameters [ 'identifier' ] ?? null ; return $ this -> fractal -> createData ( $ resource , $ identifier ) -> toArray ( ) ; }
Transform a response with a transformer.

@param mixed                                     $response
@param League\Fractal\TransformerAbstract|object $transformer
@param \Dingo\Api\Transformer\Binding            $binding
@param \Dingo\Api\Http\Request                   $request

@return array
Transform a response with a transformer .