Skip to content

[13.x] Propagate relation autoload callback in HasRelationships::setRelations() - #62362

Closed
KalimeroMK wants to merge 1 commit into
laravel:13.xfrom
KalimeroMK:fix/set-relations-propagate-autoload-callback
Closed

KalimeroMK wants to merge 1 commit into
laravel:13.xfrom
KalimeroMK:fix/set-relations-propagate-autoload-callback

Conversation

@KalimeroMK

Copy link
Copy Markdown
Contributor

HasRelationships::setRelation() and autoloadRelationsUsing() both call propagateRelationAutoloadCallbackToRelation() so relationship autoloading continues across nested relations when withRelationshipAutoloading() or Model::automaticallyEagerLoadRelationships() is active.

setRelations() replaces $this->relations without propagating the callback, causing nested relations accessed on models attached via setRelations() to fall back to N+1 lazy queries. This updates setRelations() to propagate the autoload callback to each relation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants