Get other key for this many-to-many relation.

@throws \Exception

@return string
549345
protected function getOtherKey()
    {
        if ($this->otherKey) {
            return $this->otherKey;
        }

        if (is_callable([$this->form->model(), $this->column]) &&
            ($relation = $this->form->model()->{$this->column}()) instanceof BelongsToMany
        ) {
            /* @var BelongsToMany $relation */
            $fullKey = $relation->getQualifiedRelatedPivotKeyName();

            return $this->otherKey = substr($fullKey, strpos($fullKey, '.') + 1);
        }

        throw new \Exception('Column of this field must be a `BelongsToMany` relation.');
    }
1185193
public function getForeignKey()
    {
        if ($this->_foreignKey === null) {
            $this->_foreignKey = $this->_modelKey($this->getSource()->getAlias());
        }

        return $this->_foreignKey;
    }
856987
protected function getForeignKeyName()
    {
        if (method_exists($this->relation, 'getQualifiedForeignPivotKeyName')) {
            $method = 'getQualifiedForeignPivotKeyName'; // Laravel 5.5
        } elseif (method_exists($this->relation, 'getQualifiedForeignKeyName')) {
            $method = 'getQualifiedForeignKeyName'; // Laravel 5.4
        } else {
            $method = 'getForeignKey'; // Laravel 5.3
        };

        return last(explode('.', $this->relation->$method()));
    }
212171
public function getPrimaryKey()
    {
        if (is_null($this->_primaryKey)) {
            $this->_primaryKey = $this->getDescriptor()
                ->getEntity()->getPrimaryKey();
        }
        return $this->_primaryKey;
    }
696119
public function toAssoc()
    {
        $params = [];
        foreach (Extract::getObjectVars($this) as $key => $value) {
            if (!$value instanceof Relation) {
                $params[$key] = $value;
            }
        }
        if ($this->getPrimaryKeyValue() === null) {
            unset($params[$this->getPrimaryKey()]);
        }
        return $params;
    }
652445
protected function getForeignKeyRelations() {
    if ($this->fkRelations == null) {
      $this->fkRelations = [];
      $relationDescs = $this->getRelations();
      foreach($relationDescs as $relationDesc) {
        if ($relationDesc instanceof RDBManyToOneRelationDescription) {
          $this->fkRelations[] = $relationDesc;
        }
      }
    }
    return $this->fkRelations;
  }
985263
public function getRelatedForeignKey()
    {
        if (null == $this->relatedForeignKey) {
            $name = $this->getParentTableName();
            $this->relatedForeignKey = "{$this->normalizeFieldName($name)}_id";
        }
        return $this->relatedForeignKey;
    }
202892
public function key()
	{
		if( !isset( $this->____pairs ) )
			$this->getPairs();
		$keys	= array_keys( $this->____pairs );
		return $keys[$this->____cursor];
	}
1332579
public function key()
    {
        $key = key($this->standards);

        return array_search($key, array_keys($this->standards));
    }
1331833
protected function getRelatedKeyName()
    {
        if (method_exists($this->relation, 'getQualifiedRelatedPivotKeyName')) {
            $method = 'getQualifiedRelatedPivotKeyName'; // Laravel 5.5
        } elseif (method_exists($this->relation, 'getQualifiedRelatedKeyName')) {
            $method = 'getQualifiedRelatedKeyName'; // Laravel 5.4
        } else {
            $method = 'getOtherKey'; // Laravel 5.3
        };

        return last(explode('.', $this->relation->$method()));
    }
925553
public function getWithRelation($name){
        $relations = $this->getRelations();
        if(isset($relations[$name])){
            $relation = $relations[$name];
            if($relation['relation'] === 'OTO'){
                return $this->getOneToOne($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'OTM'){
                return $this->getOneToMany($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'MTO'){
                return $this->getManyToOne($relation['target'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            elseif($relation['relation'] == 'MTM'){
                return $this->getManyToMany($relation['target'], $relation['through'], isset($relation['key'])?$relation['key']:null, isset($relation['target_key'])?$relation['target_key']:null);
            }
            else{
                throw new Exception('Invalid relation "'.$relation['relation'].'"');
            }
        }
        else{
            return false;
        }
    }
444355
public function getPrimaryKey() {
        return $this->cache(__METHOD__, function() {
            $pk = $this->getConfig('primaryKey');
            $schema = $this->getSchema();

            if ($schema->hasColumn($pk)) {
                return $pk;
            }

            if ($pk = $schema->getPrimaryKey()) {
                return $pk['columns'][0];
            }

            return 'id';
        });
    }
861795
public function keys()
    {
        if (!$this->__connect()) {
            return array();
        }

        $meta = $this->getMeta();
        if (!is_array($meta) || !array_key_exists(Memento\Hash::FIELD_KEYS, $meta)) {
            $this->__disconnect();

            return array();
        }

        $keys = $this->memcache->get($meta[Memento\Hash::FIELD_KEYS]);
        $this->__disconnect();

        if (!is_array($keys)) {
            return array();
        }

        return array_keys($keys);
    }
990659
public function getPrimaryKey()
    {
        if (null === $this->primary) {
            $metadata = $this->getMetadata();
            $constraints = $metadata->getConstraints($this->getTable());

            foreach ($constraints as $constraint) {
                if ($constraint->getType() == 'PRIMARY KEY') {
                    $this->primary = $constraint->getColumns();
                }
            }
        }

        return $this->primary;
    }
985346
public function getAssociated()
    {
        $associated = [];
        foreach (['hasMany', 'hasOne', 'belongsTo'] as $association) {
            foreach ($this->{$association} as $name => $options) {
                $associated[$name] = $association;
            }
        }
        return $associated;
    }
1311400
public function key()
    {
        $child = current($this->children);
        if (false === $child) {
            return null;
        }

        return $child->getName();
    }
360431
public function key()
	{
		$pageSize=$this->_dataProvider->getPagination()->getPageSize();
		return $this->_currentPage*$pageSize+$this->_currentIndex;
	}