public function createPivots($relatedEntities)
    {
        $keys = [];
        $attributes = [];

        $keyName = $this->relatedMap->getKeyName();

        foreach ($relatedEntities as $entity) {
            $keys[] = $entity->getEntityAttribute($keyName);
        }

        $records = $this->createAttachRecords($keys, $attributes);

        $this->query->getQuery()->from($this->table)->insert($records);
    }