Skip to content

Commit c0be602

Browse files
authored
[12.x] Fix relation auto loading with manually set relations (#55452)
1 parent f026be3 commit c0be602

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function propagateRelationAutoloadCallbackToRelation($key, $models, $c
184184

185185
foreach ($models as $model) {
186186
// Check if relation autoload contexts are different to avoid circular relation autoload...
187-
if (is_null($context) || $context !== $model) {
187+
if ((is_null($context) || $context !== $model) && is_object($model) && method_exists($model, 'autoloadRelationsUsing')) {
188188
$model->autoloadRelationsUsing($callback, $context);
189189
}
190190
}

0 commit comments

Comments
 (0)