Включаем ответы в трансформацию.

@param  PollModelContract  $item

@return FractalCollection

@throws BindingResolutionException
495337
public function includeOptions(PollModelContract $item): FractalCollection
    {
        $transformer = app()->make(
            'InetStudio\PollsPackage\Analytics\Contracts\Transformers\Back\Result\PollOptionTransformerContract',
            [
                'totalVotes' => $item['options']->sum('votes_count'),
            ]
        );

        return new FractalCollection($item['options'], $transformer);
    }
675796
public function transform(ParameterBag $item)
    {
        if (!$item->has($this->field)) {
            return;
        }

        $value = $item->get($this->field);

        try {
            $newValue = $this->transformer->transform($value);
            $item->set($this->field, $newValue);
        } catch (TransformationFailedException $e) {
            // set the value to null as we couldn't transform it
            $item->set($this->field, null);

            throw new TransformationFailedException(
                sprintf(
                    'Transforming "%s" using "%s" failed with message: %s.',
                    $this->field,
                    get_class($this->transformer),
                    $e->getMessage()
                ),
                null,
                $e
            );
        }
    }
455276
public function put(Item $item, Context\Put $context = null)
    {
        $table = $item->getTable();

        if (null !== $this->logger) {
            $this->log('Put on table '.$table);
        }

        if (empty($table)) {
            throw new \Riverline\DynamoDB\Exception\AttributesException('Item do not have table defined');
        }

        $attributes = array();
        foreach ($item as $name => $attribute) {
            /** @var $attribute \Riverline\DynamoDB\Attribute */
            if ("" !== $attribute->getValue()) {
                // Only not empty string
                $attributes[$name] = $attribute->getForDynamoDB();
            }
        }
        $parameters = array(
            'TableName' => $table,
            'Item'      => $attributes,
        );

        if (null !== $context) {
            $parameters += $context->getForDynamoDB();
        }

        if (null !== $this->logger) {
            $this->log('Put request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->putItem($parameters);

        if (null !== $this->logger) {
            $this->log('Put request response : '.print_r($response, true), Logger::DEBUG);
        }

        // Update write counter
        $this->addConsumedWriteUnits($table, floatval($response['ConsumedCapacityUnits']));

        return $this->populateAttributes($response);
    }
941216
public function setItem(\Lyon1\Bundle\PoobleBundle\Entity\SurveyItem $item = null)
    {
        $this->item = $item;

        return $this;
    }
91612
protected function checkVoteItem($item)
    {
        if ($item instanceof \Illuminate\Database\Eloquent\Model) {
            $this->setVoteRelation(get_class($item));
            return $item->id;
        };

        return $item;
    }
73646
protected function updateItem(Model $item, $data)
    {
        $this->beforeAssignData($item, $data);
        $item->assign($data, null, $this->whitelistUpdate());
        $this->afterAssignData($item, $data);

        $this->beforeSave($item);
        $this->beforeUpdate($item);

        $success = $item->update();

        if ($success) {

            $this->afterUpdate($item);
            $this->afterSave($item);
        }

        return $success ? $item : null;
    }
792370
public function saveItem(StorableInterface $item)
    {
        if ($this->tableExists() === false) {
            /** @todo Optionnally turn off for some models */
            $this->createTable();
        }

        if ($item !== null) {
            $this->setModel($item);
        }
        $model  = $this->model();
        $table  = $this->table();
        $struct = array_keys($this->tableStructure());
        $fields = $this->getModelFields($model);

        $keys   = [];
        $values = [];
        $binds  = [];
        $types  = [];
        foreach ($fields as $field) {
            $key = $field->ident();
            if (in_array($key, $struct)) {
                $keys[]      = '`'.$key.'`';
                $values[]    = ':'.$key.'';
                $binds[$key] = $field->val();
                $types[$key] = $field->sqlPdoType();
            }
        }

        $query = '
            INSERT
                INTO
            `'.$table.'`
                ('.implode(', ', $keys).')
            VALUES
                ('.implode(', ', $values).')';

        $result = $this->dbQuery($query, $binds, $types);

        if ($result === false) {
            throw new PDOException('Could not save item.');
        } else {
            if ($model->id()) {
                return $model->id();
            } else {
                return $this->db()->lastInsertId();
            }
        }
    }
124448
public function remove($item)
    {
        if (!($item instanceof $this->dataClass)) {
            throw new InvalidArgumentException(
                "HasManyList::remove() expecting a $this->dataClass object, or ID",
                E_USER_ERROR
            );
        }

        // Don't remove item with unrelated class key
        $foreignClass = $this->getForeignClass();
        $classNames = ClassInfo::subclassesFor($foreignClass);
        $classForeignKey = $this->classForeignKey;
        $classValueLower = strtolower($item->$classForeignKey);
        if (!array_key_exists($classValueLower, $classNames)) {
            return;
        }

        // Don't remove item which doesn't belong to this list
        $foreignID = $this->getForeignID();
        $foreignKey = $this->foreignKey;

        if (empty($foreignID)
            || $foreignID == $item->$foreignKey
            || (is_array($foreignID) && in_array($item->$foreignKey, $foreignID))
        ) {
            $item->$foreignKey = null;
            $item->$classForeignKey = null;
            $item->write();
        }
    }
585133
public function remove($item)
    {
        if ($item->parent() === $this->parentNode) {
            $this->checkUnlocked($item);
            $item->internalUnsetParent();
            parent::remove($item);
        }

        return $this;
    }
835302
public function get(Request $request, Fractal $fractal, FractalCollection $collection)
    {
        $this->beforeRequest($request, func_get_args());
        $transformer = $this->getTransformer();
        $includes = $request->input('include', '');
        $filter = $request->input('filter', false);
        $items = $this->getRepository();
        if ($filter && is_string($filter)) {
            $filter = json_decode($filter, true);
        }
        $queryFilter = [];
        if (!empty($filter)) {
            $queryFilter = new QueryFilter($filter, $items->model(), $this->getTransformer()); 
        }
        $fractal->parseIncludes($includes);
        $resource = $collection->setTransformer($transformer)->setResourceKey($this->getResourceKey());
        $paginator = $items->paginate($queryFilter, $transformer->getSafeEagerLoad($fractal->getRequestedIncludes()), app('context'));
        $itemCollection = $paginator->getCollection();
        $resource->setData($itemCollection);
        $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
        return $this->respondWithCollection($fractal->createData($resource));
    }
192383
public function vote($item, $type = 'up_vote')
    {
        $items = array_fill_keys((array) $this->checkVoteItem($item), ['type' => $type]);

        return $this->votedItems()->sync($items, false);
    }
1265533
public function set(CacheItem $item): self
    {
        $driver = $this->getDriver();
        $driver->set($item->key, $item->value, $item->ttl);
        if ($this->hasEventListeners('itemSet')) {
            $this->dispatchEvent('itemSet', new \BearFramework\App\Cache\ItemSetEventDetails(clone($item)));
        }
        if ($this->hasEventListeners('itemChange')) {
            $this->dispatchEvent('itemChange', new \BearFramework\App\Cache\ItemChangeEventDetails($item->key));
        }
        return $this;
    }
969963
public function attachToObject($request, $item)
    {
        if ($request->filled('widgets')) {
            $widgets = explode(',', $request->get('widgets'));
            $item->syncWidgets($this->repository->getItemsByIDs((array) $widgets));
        } else {
            $item->detachWidgets($item->widgets);
        }
    }
550392
public static function create($data = null, $transformer = null, $serializer = null)
    {
        $fractal = parent::create($data, $transformer, $serializer);

        if (config('fractal.auto_includes.enabled')) {
            $requestKey = config('fractal.auto_includes.request_key');

            if ($include = app('request')->query($requestKey)) {
                $fractal->parseIncludes($include);
            }
        }

        if (empty($serializer)) {
            $serializer = config('fractal.default_serializer');
        }

        if ($data instanceof LengthAwarePaginator) {
            $paginator = config('fractal.default_paginator');

            if (empty($paginator)) {
                $paginator = IlluminatePaginatorAdapter::class;
            }

            $fractal->paginateWith(new $paginator($data));
        }

        if (empty($serializer)) {
            return $fractal;
        }

        if ($serializer instanceof SerializerAbstract) {
            return $fractal->serializeWith($serializer);
        }

        if ($serializer instanceof Closure) {
            return $fractal->serializeWith($serializer());
        }

        if ($serializer == JsonApiSerializer::class) {
            $baseUrl = config('fractal.base_url');

            return $fractal->serializeWith(new $serializer($baseUrl));
        }

        return $fractal->serializeWith(new $serializer);
    }
63337
public function getItemModel(core_kernel_classes_Resource $item)
    {
        $returnValue = null;

        $itemModel = $item->getOnePropertyValue($this->itemModelProperty);
        if ($itemModel instanceof core_kernel_classes_Resource) {
            $returnValue = $itemModel;
        }

        return $returnValue;
    }
887562
public function remove($item)
    {
        if (!($item instanceof $this->dataClass)) {
            throw new InvalidArgumentException(
                "HasManyList::remove() expecting a $this->dataClass object, or ID",
                E_USER_ERROR
            );
        }

        // Don't remove item which doesn't belong to this list
        $foreignID = $this->getForeignID();
        $foreignKey = $this->getForeignKey();

        if (empty($foreignID)
            || (is_array($foreignID) && in_array($item->$foreignKey, $foreignID))
            || $foreignID == $item->$foreignKey
        ) {
            $item->$foreignKey = null;
            $item->write();
        }
    }
884959
public function getItem(EloquentModel $model, $transformer = null, $resourceKey = null)
    {
        $resource = new FractalItem(
            $model,
            $this->getTransformer($transformer),
            $this->getResourceKey($resourceKey)
        );

        if ($meta = $this->getMeta()) {
            $resource->setMeta($meta);
            $this->meta = [];
        }

        return $this->fractal->createData($resource)->toArray();
    }