diff --git a/src/BaseRelation.php b/src/BaseRelation.php index 031eecf..e2bd7db 100644 --- a/src/BaseRelation.php +++ b/src/BaseRelation.php @@ -144,7 +144,7 @@ public function addEagerConstraints(array $models) // The first model in the array is always the parent, so add the scope constraints based on that model. // @link https://github.com/laravel/framework/pull/25240 // @link https://github.com/lazychaser/laravel-nestedset/issues/351 - optional($models[0])->applyNestedSetScope($this->query); + optional(reset($models))->applyNestedSetScope($this->query); $this->query->whereNested(function (Builder $inner) use ($models) { // We will use this query in order to apply constraints to the