Skip to content

Commit 8c5e211

Browse files
author
Admin
committed
Fix eager load
1 parent 73a1a98 commit 8c5e211

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Eloquent/CustomRelations/Builders/CleverEloquentBuilder.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ protected function getRelationWithoutConstraints($relation): Relation
134134
*/
135135
protected function getBelongsToRelation(MorphTo $relation, $type): BelongsTo
136136
{
137-
/** this will work as before */
138137
$belongsTo = Relation::macroNoConstraints(function () use ($relation, $type): Relation {
139-
return $this->model->belongsTo(
138+
$model = $this->getModel();
139+
$model->nowEagerLoadingRelationNameWithNoConstraints = $relation->getRelationName();
140+
141+
return $model->belongsTo(
140142
$type,
141143
$relation->getForeignKeyName(),
142-
$relation->getOwnerKeyName()
144+
$relation->getOwnerKeyName(),
145+
$relation->getRelationName(),
143146
);
144-
});
147+
}, $relation->getRelationName());
145148

146149
$belongsTo->getQuery()->mergeConstraintsFrom($relation->getQuery());
147150

0 commit comments

Comments
 (0)