改进关联查询

This commit is contained in:
thinkphp
2017-04-03 09:37:31 +08:00
parent 4dd5582cdd
commit 6e5d6fa7b2
4 changed files with 16 additions and 4 deletions

View File

@@ -56,7 +56,10 @@ class MorphOne extends Relation
call_user_func_array($closure, [ & $this->query]);
}
$relationModel = $this->relation($subRelation)->find();
$relationModel->setParent(clone $this->parent);
if ($relationModel) {
$relationModel->setParent(clone $this->parent);
}
return $relationModel;
}