Returns the Meta object using given key from data object.

@param \cmsgears\core\common\models\base\ActiveRecord $model
@param string $key
@param boolean $assoc
@return boolean|\cmsgears\core\common\models\forms\Meta
559313
public function getDataMeta( $model, $key, $assoc = false ) {

		$object	= $model->generateDataObjectFromJson( $assoc );
		$meta	= new Meta();

		if( isset( $object->$key ) ) {

			$meta->key		= $key;
			$meta->value	= $object->$key;

			return $meta;
		}

		return false;
	}
638828
public function getMeta($metaKey)
    {
        /** @var Collection $matchingMeta */
        $matchingMeta = $this->meta->filter(
            function (Meta $meta) use ($metaKey) {
                return $meta->getKey() == $metaKey;
            }
        );

        return $matchingMeta->count() == 1 ? $matchingMeta->first()->getValue() : null;
    }
875368
public function getKey($field, $assoc = false)
    {
        return $assoc ? $this->get($assoc)[$field] : $this->get($assoc)->{$field};
    }
971575
public function get($key)
  {
    return isset($this->attr[$key]) ? $this->attr[$key] : false;
  }
1242790
public function getAttribute($key)
	{
		$inAttributes = array_key_exists($key, $this->attributes);

		// If the key references an attribute, we can just go ahead and return the
		// plain attribute value from the model. This allows every attribute to
		// be dynamically accessed through the _get method without accessors.
		if ($inAttributes || $this->hasGetMutator($key))
		{
			return $this->getAttributeValue($key);
		}

		// If the key already exists in the relationships array, it just means the
		// relationship has already been loaded, so we'll just return it out of
		// here because there is no need to query within the relations twice.
		if (array_key_exists($key, $this->relations))
		{
			return $this->relations[$key];
		}

		// If the "attribute" exists as a method on the model, we will just assume
		// it is a relationship and will load and return results from the query
		// and hydrate the relationship's value on the "relationships" array.
		if (method_exists($this, $key))
		{
			return $this->getRelationshipFromMethod($key);
		}
	}
88694
public function buildRelationXTypeInfo(Model $model, $key)
    {
        $relation = $model->$key();

        switch (true) {

            case $relation instanceof BelongsTo:
                return $this->buildBelongsToInfo($key, $relation);

            case $relation instanceof BelongsToMany:
                return $this->buildBelongsToManyInfo($key, $relation);

            case $relation instanceof HasMany:
                return $this->buildHasManyInfo($key, $relation);

            case $relation instanceof HasOne:
                return $this->buildHasOneInfo($key, $relation);

            case $relation instanceof HasManyThrough:
                return $this->buildHasManyThroughInfo($key, $relation);

            case $relation instanceof MorphOne:
                return $this->buildMorphOneInfo($key, $relation);

            case $relation instanceof MorphMany:
                return $this->buildMorphManyInfo($key, $relation);

            default:
                $modelClass = get_class($model);
                $relationType = Type::of($relation);

                throw new UnsupportedParameterException("Result of $modelClass->$key() did not return a Relation (it returned $relationType)");
        }
    }
1165082
public function getAttribute($key)
    {
        if (method_exists($this, $key)) {
            return $this->getRelationshipFromMethod($key);
        }

        return parent::getAttribute($this->getSnakeKey($key));
    }
931336
public function updateDataConfigObj( $model, $meta ) {

		$config = $model->getDataMeta( 'config' );
		$key	= $meta->key;
		$config	= !empty( $config ) ? $config : new \StdClass();

		$config->$key = $meta->value;

		$model->updateDataMeta( 'config', $config );

		$model->refresh();

		return $model;
	}
1242246
public static function create(Assoc $option)
    {
        $definition = $option->getDefinition();

        switch ($option->getType()) {
            case "m:n":
            case "m>n":
            case "m<n":
                return new ManyToMany(
                    $option->getSourceReflection(),
                    $option->getTargetReflection(),
                    $definition,
                    $option->getType() === "m<n" ? false : true
                );
            case "1:1":
                return new OneToOne(
                    $option->getSourceReflection(),
                    $option->getTargetReflection(),
                    isset($definition[0]) ? $definition[0] : null
                );
            case "1:n":
                return new OneToMany(
                    $option->getSourceReflection(),
                    $option->getTargetReflection(),
                    isset($definition[0]) ? $definition[0] : null
                );
            case "n:1":
                return new ManyToOne(
                    $option->getSourceReflection(),
                    $option->getTargetReflection(),
                    isset($definition[0]) ? $definition[0] : null
                );
            default:
                throw new AssociationException("Unsupported association type");
        }
    }
55741
protected function extractCacheMetadata($metakey, $value) {
		if (is_array($value) || $value instanceof \ArrayObject) {
			if (!array_key_exists($metakey, $value))
				return null;
				
			return $value[$metakey];
		}
		elseif (is_object($value)) {
			if (!property_exists($value, $metakey))
				return null;
				
			return $value->$metakey;
		}
	
		return null;
	}
736720
public function updateDataMetaObj( $model, $meta ) {

		$model->updateDataMeta( $meta->key, $meta->value );

		$model->refresh();

		return $model;
	}
773407
public function getMetaData($key)
    {
        return isset($this->meta[$key]) ? $this->meta[$key] : null;
    }
94428
protected function _containForeignModels($query, $assoc = null) {
		if (
			(isset($query['contain']) && empty($query['contain']))
			|| (isset($this->contain) && empty($this->contain))
		) {
			return $query;
		}

		if (!isset($query['contain'])) {
			$query['contain'] = array();
		} else if (!is_array($query['contain'])) {
			$query['contain'] = (array) $query['contain'];
		}

		// Add the foreign models.
		foreach (array_keys($this->belongsToForeignModels) as $model) {
			if (!empty($assoc)) {
				$model = "$assoc.$model";
			}
			if (!in_array($model, $query['contain']) && !isset($query['contain'][$model])) {
				$query['contain'][] = $model;
			}
		}

		return $query;
	}
475839
public function getData($json = true, $assoc = false)
    {
        $data = file_get_contents('php://input');
        if (!$json) {
            return $data;
        }
        return json_decode($data, $assoc);
    }
1300515
public function getAttribute($key)
    {
        // parent call first.
        if (($attr = parent::getAttribute($key)) !== null) {
            return $attr;
        }

        // there was no attribute on the model
        // retrieve the data from meta relationship
        return $this->getMeta($key);
    }
256903
public function getAttribute($key, $model = false)
    {
        if (!$key) {
            return;
        }

        if (!$model) {
            $model = $this->model;
        }

        $formattedKey = str_replace('.', '_', $key);

        if ($this->hasGetAccessor($formattedKey)) {
            $method = 'get'.Str::studly($formattedKey).'Attribute';

            return $this->{$method}($model);
        }

        if ($this->hasGetAccessor($key)) {
            $method = 'get'.Str::studly($key).'Attribute';

            return $this->{$method}($model);
        }

        if ($this->hasRelatedKey($key, $model)) {
            return $this->relatedKey($key, $model);
        }

        return $model->getAttribute($key);
    }
145905
public function meta($key = null, $value = null)
    {
        if (is_null($key)) {
            return $this->getMeta();
        }

        if (is_null($value)) {
            return $this->getMeta($key);
        }

        return $this->setMeta($key, $value);
    }