Get the pivot attributes from a model.

        :type model: eloquent.Model
426489
def _clean_pivot_attributes(self, model):
        
        values = {}
        delete_keys = []

        for key, value in model.get_attributes().items():
            if key.find('pivot_') == 0:
                values[key[6:]] = value

                delete_keys.append(key)

        for key in delete_keys:
            delattr(model, key)

        return values
292231
protected function intermediateRelation(Model $model, array $intermediateTable, $prefix)
    {
        $attributes = $this->intermediateAttributes($model, $prefix);

        $class = $intermediateTable['class'];

        if ($class === Pivot::class) {
            return $class::fromAttributes($model, $attributes, $intermediateTable['table'], true);
        }

        if (is_subclass_of($class, Pivot::class)) {
            return $class::fromRawAttributes($model, $attributes, $intermediateTable['table'], true);
        }

        /** @var \Illuminate\Database\Eloquent\Model $instance */
        $instance = new $class;

        return $instance->newFromBuilder($attributes);
    }
564533
public function pivotModel()
    {
        if (!isset($this->pivotModel)) {
            $this->pivotModel = $this->modelFactory()->get(Join::class);
        }

        return $this->pivotModel;
    }
1224462
def get_elements_attributes(parent_to_parse, element_path=None, attrib_name=None):
    

    attrs = _get_elements_property(parent_to_parse, element_path, 'attrib')

    if not attrib_name:
        return attrs

    return [attr[attrib_name] for attr in attrs if attrib_name in attr]
470609
def _get_related_fields(self, model):
        ""
        reverse_fk = self._get_all_related_objects(model)
        reverse_m2m = self._get_all_related_many_to_many_objects(model)

        fields = tuple(reverse_fk + reverse_m2m)
        names = tuple([x.get_accessor_name() for x in fields])

        return {
            ':related': dict(list(zip(names, fields))),
        }
690898
function getModel(model) {
  const schemaPaths = model.schema.paths;
  const name = model.modelName;

  const fields = extractPaths(schemaPaths, { name });

  return {
    name,
    fields,
    model
  };
}
99165
public function getDirtyRawAttributes(): array
    {
        $attributes = $this->getRawAttributes();

        $cachedAttributes = $this->getCachedRawAttributes(array_keys($attributes));

        $dirty = [];

        foreach ($attributes as $key => $value) {
            if ($this->isActualRelation($key) || $key == 'pivot') {
                continue;
            }

            if (!array_key_exists($key, $cachedAttributes) && !$value instanceof Pivot) {
                $dirty[$key] = $value;
            } elseif ($value !== $cachedAttributes[$key] &&
                !$this->originalIsNumericallyEquivalent($value, $cachedAttributes[$key])) {
                $dirty[$key] = $value;
            }
        }

        return $dirty;
    }
1252323
def get_values(self):
        
        elements_selected = {}
        for index in range(self.tree_loaded_model.rowCount()):
            element_name = str(self.tree_loaded_model.item(index).text())
            if element_name in self.elements_old:
                elements_selected.update({element_name: self.elements_old[element_name]})
            elif element_name in self.elements_from_file:
                elements_selected.update({element_name: self.elements_from_file[element_name]})


        return elements_selected
247739
public function getAttributes($model, array $fields = null)
    {
        $attributes = $this->attributes($model);

        if ($fields !== null) {
            $attributes = array_only($attributes, $fields);
        }

        return $attributes;
    }
1143316
def get_model_fields(self):
        

        model_fields = getattr(self.Meta, 'fields', None)

        if model_fields is not None:
            model_fields = set(model_fields)

        return model_fields
198182
public function toArray()
    {
        $relations = [];
        $arrayableRelations = [];

        // include any relations exposed by default
       foreach ($this->exposedRelations as $relation) {
            // skip loading a relation if it is from a method
            if (in_array($relation, $this->relationsFromMethod)) {
                // if the relation hasnt been loaded, then load it
                if (!isset($this->$relation)) {
                    $this->$relation = $this->$relation();
                }

                $arrayableRelations[$relation] = $this->$relation;
                continue;
            }

            $this->load($relation);
        }

        // fetch the relations that can be represented as an array
        $arrayableRelations = array_merge($this->getArrayableRelations(), $arrayableRelations);

        // add the relations to the linked array
        foreach ($arrayableRelations as $relation => $value) {
            if (in_array($relation, $this->hidden)) {
                continue;
            }

            if ($value instanceof Pivot) {
                continue;
            }

            if ($value instanceof BaseModel) {
                $relations[$relation] = array('linkage' => array('id' => (string)$value->getKey(), 'type' => $value->getResourceType()));
            } elseif ($value instanceof Collection) {
                $relation = \str_plural($relation);
                $items = ['linkage' => []];
                foreach ($value as $item) {
                    $items['linkage'][] = array('id' => (string)$item->getKey(), 'type' => $item->getResourceType());
                }
                $relations[$relation] = $items;
            }

            // remove models / collections that we loaded from a method
            if (in_array($relation, $this->relationsFromMethod)) {
                unset($this->$relation);
            }
        }

        //add type parameter
        $model_attributes = $this->attributesToArray();
        unset($model_attributes[$this->primaryKey]);

        $attributes = [
            'id'         => (string)$this->getKey(),
            'type'       => $this->getResourceType(),
            'attributes' => $model_attributes
        ];

        if (! count($relations)) {
            return $attributes;
        }

        return array_merge(
            $attributes,
            [ 'links' => $relations ]
        );
    }
1345534
def related_model(self):
        
        relationship_field = self.name

        if relationship_field not in get_relationships(self.schema):
            raise InvalidFilters("{} has no relationship attribute {}".format(self.schema.__name__, relationship_field))

        return getattr(self.model, get_model_field(self.schema, relationship_field)).property.mapper.class_
1244107
def get(self, *args, **kwargs):
        """"""
        self.before_get(args, kwargs)

        relationship_field, model_relationship_field, related_type_, related_id_field = self._get_relationship_data()

        obj, data = self._data_layer.get_relationship(model_relationship_field,
                                                      related_type_,
                                                      related_id_field,
                                                      kwargs)

        result = {'links': {'self': request.path,
                            'related': self.schema._declared_fields[relationship_field].get_related_url(obj)},
                  'data': data}

        qs = QSManager(request.args, self.schema)
        if qs.include:
            schema = compute_schema(self.schema, dict(), qs, qs.include)

            serialized_obj = schema.dump(obj)
            result['included'] = serialized_obj.data.get('included', dict())

        final_result = self.after_get(result)

        return final_result
1013548
public static function fromAttributes(Model $parent, $attributes, $table, $exists = false)
    {
        $instance = new static;

        $instance->timestamps = $instance->hasTimestampAttributes($attributes);

        // The pivot model is a "dynamic" model since we will set the tables dynamically
        // for the instance. This allows it work for any intermediate tables for the
        // many to many relationship that are defined by this developer's classes.
        $instance->setConnection($parent->getConnectionName())
            ->setTable($table)
            ->forceFill($attributes)
            ->syncOriginal();

        // We store off the parent instance so we will access the timestamp column names
        // for the model, since the pivot model timestamps aren't easily configurable
        // from the developer's point of view. We can use the parents to get these.
        $instance->pivotParent = $parent;

        $instance->exists = $exists;

        return $instance;
    }
520751
public function nodeAttributes($model = false, $pid = '', $uniqueKey = false)
    {
        $uniqueKey = $uniqueKey ? $uniqueKey : self::$uniqueKey++;
        $model     = ($model) ? $model : $this->owner;
        $id        = $model[$this->id];
        $nodeId    = $uniqueKey . '-id-' . $id;

        return array(
            'id'       => $nodeId,
            'model'    => $model,
            'children' => $model[$this->childrenAttribute],
            'text'     => $model['name'],
            'type'     => $model['type'] == 1 ? 'user' : 'flag',
            'selected' => in_array($model[$this->id], $this->selectedNodes),
            'a_attr'   => array(
                'class'   => 'jstree-clicked',
                'data-id' => $nodeId,
                'href'      => [$this->actionPath, $this->id => $id, 'pid'=> $pid]
            )
        );
    }
286455
protected function resolvePivot($pivot)
    {
        if (empty($pivot)) {
            return null;
        }

        if ($pivot instanceof JoinInterface) {
            return $pivot;
        }

        $data  = $pivot;
        $pivot = $this->modelFactory()->create(Join::class);

        if (is_string($data) && strpos($data, '_') > 1) {
            $data = array_combine([ 'obj_type', 'obj_id' ], explode('_', $data, 1));
        }

        if (is_scalar($data)) {
            return $pivot->load($data);
        } elseif (is_array($data)) {
            $data = array_merge([
                'obj_type'      => null,
                'obj_id'        => null,
                'attachment_id' => null,
                'group'         => AttachmentContainerInterface::DEFAULT_GROUPING,
            ], $data);

            if ($this instanceof AttachableInterface) {
                if (!isset($data['attachment_id']) && $this->id()) {
                    $data['attachment_id'] = $this->id();
                }
            } elseif ($this instanceof AttachmentAwareInterface) {
                if (!isset($data['obj_id']) && $this->id()) {
                    $data['obj_id'] = $this->id();
                }

                if (!isset($data['obj_type'])) {
                    $data['obj_type'] = $this->objType();
                }
            }

            if (isset($data['obj_type']) && isset($data['obj_id'])) {
                $pivot->setObjectType($data['obj_type']);
                $pivot->setObjectId($data['obj_id']);
                $pivot->setGroup($data['group']);

                if (isset($data['attachment_id'])) {
                    $pivot->setAttachmentId($data['attachment_id']);

                    $query = '
                        SELECT
                            *
                        FROM
                           `%table`
                        WHERE 1 = 1
                           AND `%obj_type` = :obj_type
                           AND `%obj_id` = :obj_id
                           AND `%att_id` = :att_id
                           AND `%group`  = :group
                        LIMIT
                           1';

                    $query = strtr($query, [
                        '%table'    => $pivot->source()->table(),
                        '%obj_type' => 'object_type',
                        '%obj_id'   => 'object_id',
                        '%att_id'   => 'attachment_id',
                        '%group'    => 'group',
                    ]);

                    $binds = [
                        'obj_type' => $data['obj_type'],
                        'obj_id'   => $data['obj_id'],
                        'att_id'   => $data['attachment_id'],
                        'group'    => $data['group'],
                    ];

                    $pivot->loadFromQuery($query, $binds);
                }

                return $pivot;
            } else {
                throw new InvalidArgumentException('Invalid Pivot Array Structure');
            }
        }

        return $pivot;
    }
886042
def formpivot(self):
        '''
        
        '''

        self.ignore(whitespace)

        self.nextmust('->')

        self.ignore(whitespace)

        if self.nextchar() == '#':
            match = self.tagmatch()
            return s_ast.PivotToTags(kids=(match,))

        # check for pivot out syntax
        if self.nextchar() == '*':
            self.offs += 1
            return s_ast.PivotOut()

        prop = self.absprop()
        return s_ast.FormPivot(kids=(prop,))