mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
Query类relation支持嵌套关联
This commit is contained in:
@@ -39,10 +39,11 @@ class MorphTo extends Relation
|
||||
|
||||
/**
|
||||
* 延迟获取关联数据
|
||||
* @param string $subRelation 子关联名
|
||||
* @param \Closure $closure 闭包查询条件
|
||||
* @access public
|
||||
*/
|
||||
public function getRelation($closure = null)
|
||||
public function getRelation($subRelation = '', $closure = null)
|
||||
{
|
||||
$morphKey = $this->morphKey;
|
||||
$morphType = $this->morphType;
|
||||
@@ -50,7 +51,7 @@ class MorphTo extends Relation
|
||||
$model = $this->parseModel($this->parent->$morphType);
|
||||
// 主键数据
|
||||
$pk = $this->parent->$morphKey;
|
||||
return (new $model)->find($pk);
|
||||
return (new $model)->relation($subRelation)->find($pk);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user