*
Gets the m2m relationship field on the through model.
@param Model $model
@param       $attr
@return mixed
@author: Eddilbert Macharia (http://eddmash.com)<edd.cowan@gmail.com>
488807
public function getM2MAttr(ForeignObjectRel $relation, $attr)
    {
        $cache_attr = sprintf('_m2m_%s_cache', $attr);
        if ($this->hasProperty($cache_attr)) {
            return $this->{$cache_attr};
        }

        $linkName = null;
        if ($this->relation->throughFields) {
            $linkName = $this->relation->throughFields[0];
        }

        $fromModel = $relation->getFromModel()->getMeta()->getNSModelName();
        /** @var $field RelatedField */
        foreach ($this->relation->through->getMeta()->getFields() as $field) {
            if ($field->isRelation && (is_null($linkName) || $linkName == $field->getName()) &&
                $field->relation->toModel->getMeta()->getNSModelName() == $fromModel) {
                $this->{$cache_attr} = ('name' == $attr) ? call_user_func([$field, 'getName']) : $field->{$attr};

                return $this->{$cache_attr};
            }
        }
    }
518663
function attribute( $attr )
    {
        if ( isset( $this->Attributes[$attr] ) )
        {
            return $this->$attr();
        }
        else if ( $attr == 'wwwdir' )
        {
            return $this->wwwDir();
        }
        else if ( $attr == 'sitedir' )
        {
            return $this->siteDir();
        }
        else if ( $attr == 'indexfile' )
        {
            return $this->indexFile();
        }
        else if ( $attr == 'indexdir' )
        {
            return $this->indexDir();
        }
        else if ( $attr = 'querystring' )
        {
            return $this->queryString();
        }

        eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
        return null;
    }
1251511
public static function get(Model $model)
    {
        return Mention::where('model_type', get_class($model))
            ->where('model_id', $model->getKey())
            ->get();
    }
136907
protected function getAttrName($attr)
    {
        $name = strtolower($attr);
        if (array_key_exists($name, $this->_map)) {
            $attr = $this->_map[$name];
        }
        return $attr;
    }
657908
public function getAttribute($attr)
    {
        return isset($this->attributes[$attr]) ? $this->attributes[$attr] : null;
    }
299653
def model_attr(attr_name):
    

    def model_attr(_value, context, **_params):
        value = getattr(context["model"], attr_name)
        return _attr(value)

    return model_attr
895901
public function hasAttribute( $attr )
    {
        $def = $this->definition();
        $has_attr = isset( $def["fields"][$attr] );
        if ( !$has_attr and isset( $def["function_attributes"] ) )
            $has_attr = isset( $def["function_attributes"][$attr] );
        if ( !$has_attr and isset( $def["functions"] ) )
            $has_attr = isset( $def["functions"][$attr] );
        return $has_attr;
    }
1298984
public function getAttribute($attr) {
        $url = "entities/{$this->_id}/attrs/$attr";

        if ($this->_type) {
            $url .= "?type={$this->_type}";
        }

        return $this->_orion->get($url);
    }
1278060
protected function getModelValueAttribute($model, $name)
    {
        $transformedName = $this->transformKey($name);
        if (is_string($model)) {
            return $model;
        } elseif (is_object($model)) {
            return object_get($model, $transformedName);
        } elseif (is_array($model)) {
            return array_get($model, $transformedName);
        }
    }
1275554
def use_model_attr(attr):
    """"""

    def use_model_validator(instance, attribute, value):
        getattr(instance, attr)(instance, attribute, value)
    return use_model_validator
610375
public function setModelDefaults($attr, $value = null)
    {
        if (is_array($attr))
            $this->modelDefaults = array_merge($this->modelDefaults, $attr);
        else
            $this->modelDefaults[$attr] = $value;

        return $this;
    }
917982
protected function getDefaultFor(Model $model)
    {
        if (! $this->withDefault) {
            return;
        }

        $instance = $this->related->newInstance();

        $foreignKey = $this->getForeignKeyName();

        if (is_array($foreignKey)) { //Check for multi-columns relationship
            foreach ($foreignKey as $index => $key) {
                $instance->setAttribute($key, $model->getAttribute($this->localKey[$index]));
            }
        } else {
            $instance->setAttribute($foreignKey, $model->getAttribute($this->localKey));
        }

        if (is_callable($this->withDefault)) {
            return call_user_func($this->withDefault, $instance) ?: $instance;
        }

        if (is_array($this->withDefault)) {
            $instance->forceFill($this->withDefault);
        }

        return $instance;
    }
1071851
protected function getCategoryIdFromMetadata(array $attr)
    {

        // load the metadata of the passed URL rewrite entity
        $metadata = $this->getMetadata($attr);

        // return the category ID from the metadata
        return (integer) $metadata[UrlRewriteObserver::CATEGORY_ID];
    }
140374
def model_field_attr(model, model_field, attr):
    
    fields = dict([(field.name, field) for field in model._meta.fields])
    return getattr(fields[model_field], attr)
1098308
private function _resolveRelations($attr)
    {
        $many = self::_checkAndReturnMany($attr, $this->_data[self::getPK()]);
        if ($many) {
            return $many;
        }

        $belongs = $this->_checkAndReturnBelongs($attr, $this->_data);
        if ($belongs) {
            return $belongs;
        }

        $has_one = $this->_checkAndReturnHasOne($attr, $this->_data[self::getPK()]);
        if ($has_one) {
            return $has_one;
        }
        return null;
    }
614549
protected function getModuleByModel(Model $model)
    {
        /** @var ModuleManagerInterface $modules */
        $modules = app(ModuleManagerInterface::class);

        return $modules->getByAssociatedClass(get_class($model));
    }
1163461
public function attr($attribute, $value = null)
    {
        if (is_array($attribute)) return $this->attributes($attribute);
        if ($value) return $this->attributes(array($attribute => $value));
    }