LMongo\Eloquent\Relations\HasOneOrMany::addEagerConstraints PHP Method

addEagerConstraints() public method

Set the constraints for an eager load of the relation.
public addEagerConstraints ( array $models ) : void
$models array
return void
    public function addEagerConstraints(array $models)
    {
        $value = $this->getKeys($models);
        $value = array_map(function ($value) {
            return $value instanceof MongoID ? $value : new MongoID($value);
        }, $value);
        $this->query->whereIn($this->foreignKey, $value);
    }

Usage Example

Esempio n. 1
0
 /**
  * Set the constraints for an eager load of the relation.
  *
  * @param  array  $models
  * @return void
  */
 public function addEagerConstraints(array $models)
 {
     parent::addEagerConstraints($models);
     $this->query->where($this->morphType, $this->morphClass);
 }