Set the constraints for an eager load of the relation.

@param  array  $models
@return void
490296
public function addEagerConstraints(array $models)
    {
        $this->query->whereIn($this->getQualifiedForeignKeyName(), $this->getKeys($models));
    }
701905
public function addToRemoveModels(array $models): RelatedModelManipulationStack
    {
        foreach ($models as $model) {
            $this->addToRemoveModel($model);
        }

        return $this;
    }
1147233
public function setAllowOrders(array $orders = []): void
    {
        $this->allowOrders = [];
        foreach ($orders as $column) {
            $this->addAllowOrder($column);
        }
    }
313540
public function addEagerConstraints(array $models)
    {
        if (is_array($this->ownerKey)) { //Check for multi-columns relationship
            $keys = [];

            foreach ($this->ownerKey as $key) {
                $keys[] = $this->related->getTable().'.'.$key;
            }

            $this->query->whereIn($keys, $this->getEagerModelKeys($models));
        } else {
            // We'll grab the primary key name of the related models since it could be set to
            // a non-standard name and not "id". We will then construct the constraint for
            // our eagerly loading query so it returns the proper models from execution.
            $key = $this->related->getTable().'.'.$this->ownerKey;
            $this->query->whereIn($key, $this->getEagerModelKeys($models));
        }
    }
333018
def eager_load_relations(self, models):
        
        for name, constraints in self._eager_load.items():
            if name.find('.') == -1:
                models = self._load_relation(models, name, constraints)

        return models
178503
public function initRelation(array $models, $relation)
    {
        foreach ($models as $model) {
            $model->setRelation($relation, []);
        }
        return $models;
    }
611172
public function setRelations($relations)
    {
        $this->setAvailableIncludes(array_unique(array_merge($this->availableIncludes, (array) $relations)));

        return $this;
    }
31457
public function setEntitiesAttribute($entities): void
    {
        static::saved(function ($model) use ($entities) {
            $this->entities()->delete();
            ! $entities || $this->entities()->createMany(array_map(function ($entity) {
                return ['entity_type' => $entity];
            }, $entities));
        });
    }
391835
public function setRelatedModels($models)
    {
        $models = $this->parseAsArray($models);
        foreach ($models as $i => $model) {
            if (is_string($model)) {
                list($model, $prop) = $this->resolveRelatedModel($model);
                $models[$i]                                 = $model;
                $this->relatedProperties[$model->objType()] = $prop;
            } elseif ($model instanceof ModelInterface) {
                if (!isset($this->relatedProperties[$model->objType()])) {
                    throw new InvalidArgumentException(
                        sprintf(
                            'The related model [%s] requires a target property',
                            get_class($model)
                        )
                    );
                }
                $models[$i] = $model;
            } else {
                throw new InvalidArgumentException(
                    sprintf(
                        'A related model must be defined as "%s"',
                        'ObjType:propertyIdent'
                    )
                );
            }
        }

        $this->relatedModels = $models;

        return $this;
    }
1146008
public function setExtraModelValues(array $fields, &$model)
    {
        //make sure the relationships are loaded
        foreach ($fields as $name => $field) {
            if ($field->getOption('relationship')) {
                $this->setModelRelationship($model, $field);
            }

            //if this is a setter field, unset it
            if ($field->getOption('setter')) {
                $model->__unset($name);
            }
        }
    }
1325824
protected function loadMissingRelation(self $models, array $path)
    {
        $relation = array_shift($path);

        $name = explode(':', key($relation))[0];

        if (is_string(reset($relation))) {
            $relation = reset($relation);
        }

        $models->filter(function ($model) use ($name) {
            return ! is_null($model) && ! $model->relationLoaded($name);
        })->load($relation);

        if (empty($path)) {
            return;
        }

        $models = $models->pluck($name);

        if ($models->first() instanceof BaseCollection) {
            $models = $models->collapse();
        }

        $this->loadMissingRelation(new static($models), $path);
    }
259466
public function linkToMany($model, $link): void
    {
        Relations::setRelations($this->model, $model, [$link]);
    }
1152949
public function addToPersistModels(array $models): RelatedModelManipulationStack
    {
        foreach ($models as $model) {
            $this->addToPersistModel($model);
        }

        return $this;
    }
1322012
def add_eager_constraints(self, models):
        
        key = "%s.%s" % (self._related.get_table(), self._other_key)

        self._query.where_in(key, self._get_eager_model_keys(models))
1139066
public function addConstraints()
    {
        if (static::$constraints) {
            // For belongs to relationships, which are essentially the inverse of has one
            // or has many relationships, we need to actually query on the primary key
            // of the related models matching on the foreign key that's on a parent.
            $this->query->where($this->otherKey, '=', $this->parent->{$this->foreignKey});
        }
    }
886311
protected function getEagerModelKeys(array $models)
    {
        // First we need to gather all of the keys from the parent models so we know what
        // to query for via the eager loading query. We will add them to an array then
        // execute a "where in" statement to gather up all of those related records.
        $keys = collect($models)->map(function ($model) {
            return $model->{$this->foreignKey};
        })->filter()->all();

        // If there are no keys that were not null we will just return an array with either
        // null or 0 in (depending on if incrementing keys are in use) so the query wont
        // fail plus returns zero results, which should be what the developer expects.
        if (count($keys) === 0) {
            return [$this->relationHasIncrementingId() ? 0 : null];
        }

        return array_values(array_unique($keys));
    }
177824
def add_eager_constraints(self, models):
        
        self._models = Collection.make(models)
        self._build_dictionary(models)