src/Models/BaseBitrixModel.php
protected function createRelationQuery($class, $foreignKey, $localKey, $multiple)
    {
        /* @var $class BaseBitrixModel */
        /* @var $query BaseQuery */
        $query = $class::query();
        $query->foreignKey = $localKey;
        $query->localKey = $foreignKey;
        $query->primaryModel = $this;
        $query->multiple = $multiple;
        return $query;
    }
protected function createRelationQuery($class, $foreignKey, $localKey, $multiple)
    {
        /* @var $class BaseBitrixModel */
        /* @var $query BaseQuery */
        $query = $class::query();
        $query->foreignKey = $localKey;
        $query->localKey = $foreignKey;
        $query->primaryModel = $this;
        $query->multiple = $multiple;
        return $query;
    }
Creates a query instance for `has-one` or `has-many` relation.
@param string $class the class name of the related record.
@param string $foreignKey
@param string $localKey
@param bool $multiple whether this query represents a relation to more than one record.
@return BaseQuery the relational query object.
@see hasOne()
@see hasMany()