Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d34d857

Browse files
update newCollection override to account for automatic eager loading (#10737)
due to the new "automatic eager loading" feature, and the changes made here: laravel/framework@5548f95 the programmer needs to also include these changes when using the `newCollection()` method override for a custom collection, if they want the automatic eager loading feature to work correctly.
1 parent 48dac93 commit d34d857

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎eloquent-collections.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,13 @@ class User extends Model
335335
*/
336336
public function newCollection(array $models = []): Collection
337337
{
338-
return new UserCollection($models);
338+
$collection = new UserCollection($models);
339+
340+
if (Model::isAutomaticallyEagerLoadingRelationships()) {
341+
$collection->withRelationshipAutoloading();
342+
}
343+
344+
return $collection;
339345
}
340346
}
341347
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /