Skip to content

Commit 54c9a85

Browse files
committed
KeyName as default value for ownerKey;
1 parent 5387d54 commit 54c9a85

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Eloquent/HybridRelations.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
212212

213213
[$type, $id] = $this->getMorphs(Str::snake($name), $type, $id);
214214

215+
if ($ownerKey === null){
216+
$ownerKey = $this->getKeyName();
217+
}
218+
215219
// If the type value is null it is probably safe to assume we're eager loading
216220
// the relationship. When that is the case we will pass in a dummy query as
217221
// there are multiple types in the morph and we can't use single queries.

0 commit comments

Comments
 (0)