@param $builder
@param $transformer
@param string $key

@return JsonResponse
769652
protected function respondWithCollection($builder, $transformer, string $key = 'data'): JsonResponse
    {
        if (to_boolean($this->request->get('paginate', true)) === false) {
            $collection = fractal()->collection($builder)
                ->transformWith($transformer)
                ->withResourceName($key)
                ->toArray();

            $collection['meta'] = [
                'service' => env('APP_SERVICE_NAME'),
                'entity' => $transformer->getEntity()
            ];
        } else {
            $collection = $this->paginatedCollection(
                $builder,
                $transformer,
                $key,
                $this->request->get('per_page', 20)
            );
        }

        $collection['meta'] = $collection['meta'] ?? [];
        $collection['meta']['service'] = env('APP_SERVICE_NAME');
        $collection['meta']['entity'] = $transformer->getEntity();

        return $this->respondWithSuccess(
            $collection
        );
    }
117715
public function handleBuilder($builder, $value)
    {
        foreach ($value as $orderByClause) {
            $builder->orderBy(
                $orderByClause['field'],
                $orderByClause['order']
            );
        }

        return $builder;
    }
938465
public function getSetting($key, $transform = null)
    {
        if (isset($transform[$key])) {
            return $transform[$key];
        }

        return $this[$key];
    }
929840
public function build($builder, $parameters) {
		$instance = $this->builder->build($builder, $parameters);

		return $instance;
	}
954865
public function with($transformer)
    {
        $concrete = self::getTransformerFactory()->make($transformer);

        $this->resource->setTransformer($concrete);

        return Presentation::of($this->resource);
    }
1272873
public function addBuilder($builder_name, VanillaSessionBuilder $builder)
    {
        $this->builders[$builder_name] = $builder;
        $this->post_configurations[$builder_name] = [];

        if ($this->default === null) {
            $this->setDefaultBuilder($builder_name);
        }

        return $this;
    }
780556
public function collection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [])
    {
        if (!is_object($transformer) && !is_callable($transformer)) {
            $transformer = $this->di->getShared($transformer);
        }

        $resource = new Collection($data, $transformer, $resourceKey);

        foreach ($meta as $metaKey => $metaValue) {
            $resource->setMetaValue($metaKey, $metaValue);
        }

        if (!is_null($cursor)) {
            $resource->setCursor($cursor);
        }

        $rootScope = $this->getManager()->createData($resource);

        return $rootScope->toArray();
    }
38078
public function collection( $collection, $transformer = null )
    {

        // Prevent error if include dont work
        // This only returns null
        if ( ! $collection ) {
            return $this->formatOutput([]);
        }

        // Check if we should call this function on another transformer
        if ( $transformer ) {
            return $transformer->collection( $collection );
        }

        // Build an data array to return
        $returnArray = [];
        foreach ($collection as $item) {
            $returnArray[] = $this->callTransform( $item );
        }

        // Format output
        return $this->formatOutput( $returnArray );
    }
696282
public function setBuilder($group, ServiceBuilder $builder)
    {
        $this[$group] = $builder;
        $this->removed[$group] = array();
        return $this;
    }
42490
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if (null !== $options['class']){
            $this->transformer->setClass($options['class']);
            $builder->addModelTransformer($this->transformer);
        }   
    }
1163548
protected function resolveQueryFor(Builder $builder, string $filter) : Builder
    {
        $factory = $this->allowed[$filter];

        $input = $this->wantsByPrices($filter)
            ? $this->prices()
            : $this->request[$filter];

    	return (new $factory($input, $builder))->query();
    }
545678
protected function fireTransformer($transformer, $data)
    {
        $includedData = [];

        if (is_callable($transformer)) {
            $transformedData = call_user_func($transformer, $data);
        } else {
            $transformer->setCurrentScope($this);
            $transformedData = $transformer->transform($data);
        }

        if ($this->transformerHasIncludes($transformer)) {
            $includedData = $this->fireIncludedTransformers($transformer, $data);
            $transformedData = $this->manager->getSerializer()->mergeIncludes($transformedData, $includedData);
        }

        //Stick only with requested fields
        $transformedData = $this->filterFieldsets($transformedData);

        return [$transformedData, $includedData];
    }
182967
public function scopeHasAttribute(Builder $builder, string $key, $value): Builder
    {
        return $builder->whereHas($key, function (Builder $builder) use ($value) {
            $builder->where('content', $value)->where('entity_type', $this->getMorphClass());
        });
    }
476673
@Override
  public ServiceBuilderAmp service(Key<?> key, Class<?> api)
  {
    Objects.requireNonNull(api);
    
    //return newService().service(key, api);
    //throw new UnsupportedOperationException();
    return new ServiceBuilderImpl(this, api, key);
  }
1198155
public function index($builder = null)
    {
        $models = $this->repository->all([], true);

        return response()->json($models, 200);
    }
410753
public function createFromBuilder(Builder $builder)
    {
        $this->model = $builder->getModel();
        $this->query = $builder;

        $this->build();

        return $this;
    }
10363
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $transformerStrategy = $options['transformer'];
        if ($transformerStrategy === 'auto') {
            $transformerStrategy = $options['multiple'] ? 'multiple' : 'class';
        }

        switch ($transformerStrategy) {
            case 'class':
                $builder->addViewTransformer(new ClassTransformer($this->quicklist, $options['repo']));
                break;

            case 'none':
                $builder->addViewTransformer(new NoneTransformer($this->quicklist, $options['repo']));
                break;

            case 'multiple':
                $builder->addViewTransformer(new MultipleTransformer(new ClassTransformer($this->quicklist, $options['repo'])));
                break;

            case 'multiple_none':
                $builder->addViewTransformer(new MultipleTransformer(new NoneTransformer($this->quicklist, $options['repo'])));
                break;
        }
    }