Skip to content

Commit 692461e

Browse files
committed
Merge branch 'master' of github.com:jenssegers/laravel-mongodb into add-matrix-mongodb
2 parents f3021c2 + 69e4da5 commit 692461e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

src/Jenssegers/Mongodb/Eloquent/HybridRelations.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
184184
// there are multiple types in the morph and we can't use single queries.
185185
if (($class = $this->$type) === null) {
186186
return new MorphTo(
187-
$this->newQuery(), $this, $id, null, $type, $name
187+
$this->newQuery(), $this, $id, $ownerKey, $type, $name
188188
);
189189
}
190190

@@ -195,8 +195,10 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
195195

196196
$instance = new $class;
197197

198+
$ownerKey = $ownerKey ?? $instance->getKeyName();
199+
198200
return new MorphTo(
199-
$instance->newQuery(), $this, $id, $instance->getKeyName(), $type, $name
201+
$instance->newQuery(), $this, $id, $ownerKey, $type, $name
200202
);
201203
}
202204

0 commit comments

Comments
 (0)