returns a clean/dry model from a relation
@param string $key
@return Cortex
420470
public function rel($key) {
		$rt = $this->fieldConf[$key]['relType'];
		$rc = $this->fieldConf[$key][$rt];
		if (!is_array($rc))
			$rc = array($rc,'_id');
		return $this->getRelInstance($rc[0],null,$key);
	}
346559
public function getLastByKey($key)
    {
        if ($this->key == $key) return $this;

        return $this->children->getLastByKey($key);
    }
1257275
protected function getRepository($key)
    {
        $rep = $this->entityRepositories[$key];
        if ($rep) {
            return $this->getEntityManager()->getRepository($rep);
        }
    }
270661
public function getRelationValue($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 ($this->relationLoaded($key)) {
      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);
    }

    $meta = PostMeta::where([ 
    	'post_id' => $this->id, 
    	'meta_key' => '_' . $key
    ])->first();

    if ($meta) {
    	return $meta->value;
    }
  }
870837
public function getFromCache($key)
  {
    $value = $this->memcache->get($this->buildMKey($key));
    if ($value) {
      return unserialize($value);
    }
    return null;
  }
626427
public function get($key = 'aliases')
    {
        return collect($this->getManifest())->flatMap(function ($configuration) use ($key) {
            return (array) ($configuration[$key] ?? []);
        })->filter()->all();
    }
1071026
public function make($key)
    {
        switch ($key) {
            case 'config': return $this->config;
            case 'em': return $this->entityManager;
            case 'extension': return $this->extensionManager;
            case 'migration': return $this->migrationManager;
            case 'log': return $this->logger;
            case 'file': return $this->files;
            default: return $this;
        }
    }
904483
public function remove($key)
    {
        if ($this->isAcceptable($key)) {
            $key = $this->modelKey($key);
        }

        unset($this->objects[$key]);

        return $this;
    }
1102849
public function getConnectionByKey($key)
    {
        $hash = $this->strategy->getSlotByKey($key);
        $node = $this->distributor->getBySlot($hash);

        return $node;
    }
1058355
public function clear($key = null)
    {
        if (func_num_args() === 0) {
            $this->attributes = array();
        } elseif ($key === '$id') {
            throw new Exception('[Norm/Model] Restricting clear for $id.');
        } else {
            unset($this->attributes[$key]);
        }

        return $this;
    }
45284
public function getAttributeFromMeta($key)
    {
        if (! $key) {
            return;
        }

        // Here we will determine if the model base class itself contains this given key
        // since we do not want to treat any of those methods are relationships since
        // they are all intended as helper methods and none of these are relations.
        if (method_exists(self::class, $key)) {
            return;
        }

        $meta = json_decode($this->getAttribute('meta'));
        if (isset($meta->$key)) {
            return $meta->$key;
        }

        $user = $meta->user;
        if (isset($user->$key)) {
            return $user->$key;
        }
    }
511262
protected function createChild($key)
    {
        $relation = $this->getValueOrRelationForKey($key);
        // if this is not a relation, then it's the actual value
        // returned by a method (like for example computed attributes)
        // so we just return it as the value

        if (!$relation instanceof Relation) {
            return $relation;
        }

        $this->supportedRelationOrThrow($key, $relation);

        // TODO we need to bind the relation to the datasource here
        $model = Rel::make($relation)->getChild();

        if (!$this->isEloquentObject($model)) {
            throw new \LogicException(sprintf(
                'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)',
                get_type_class($model),
                get_type_class($this->getDelegatedStorage()), $key, get_type_class($relation)
            ));
        }

        return $model;
    }
1367497
protected function getByKey($key)
    {
        return $this->propertyBag()
            ->where('resource_id', $this->resource->getKey())
            ->where('key', $key)
            ->first();
    }
916908
public function restore($key)
    {
        if (isset($this->cachedObjects[$key])) {
            return $this->cachedObjects[$key];
        }

        return null;
    }
1189575
public function getAttribute($key)
    {
        // If the key references an attribute, return its plain value from the model.
        if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key)) {
            return $this->getAttributeValue($key);
        }

        // If the key already exists in the relationships array...
        else if (array_key_exists($key, $this->relations)) {
            return $this->relations[$key];
        }

        // If the "attribute" exists as a method on the model, it is a relationship.
        $camelKey = Str::camel($key);

        if (method_exists($this, $camelKey)) {
            return $this->getRelationshipFromMethod($key, $camelKey);
        }
    }
832986
protected function objectForKey($key) {
		if ($this->keyField == 'ID') {
			return ExternalContent::getDataObjectFor($key);
		} else {
			return DataObject::get_one($this->sourceObject, "\"{$this->keyField}\" = '" . Convert::raw2sql($key) . "'");
		}
	}
535760
protected function getOneByCompoundKey($key)
	{
		$sanitizedKey = [];

		// We can can potentially accept an associaitve or standard array.
		if($this->isAssociativeArray($key))
		{
			if(array_key_exists('entity_type', $key) && array_key_exists('entity_id', $key))
			{
				$sanitizedKey['entity_type'] = $key['entity_type'];
				$sanitizedKey['entity_id']   = $key['entity_id'];
			}
			else
			{
				return new Payload(null, 'insufficient_entity_key');
			}
		}
		else
		{
			$sanitizedKey['entity_type'] = $key[0];
			$sanitizedKey['entity_id']   = $key[1];
		}

		return $this->aggregate[$this->formatEntityType($sanitizedKey['entity_type'])]->first(
			['filter' => ['id' => $sanitizedKey['entity_id']]]
		);
	}