diff --git a/src/Eloquent/Relations/Siblings.php b/src/Eloquent/Relations/Siblings.php index 59fbec1..d2803ca 100644 --- a/src/Eloquent/Relations/Siblings.php +++ b/src/Eloquent/Relations/Siblings.php @@ -67,11 +67,15 @@ public function addEagerConstraints(array $models) { $keys = $this->getKeys($models, $this->localKey); - $this->query->whereIn($this->foreignKey, $keys); + $this->query->where( + function (Builder $query) use ($keys) { + $query->whereIn($this->foreignKey, $keys); - if (in_array(null, $keys, true)) { - $this->query->orWhereNull($this->foreignKey); - } + if (in_array(null, $keys, true)) { + $query->orWhereNull($this->foreignKey); + } + } + ); } /**