think\model\Relation::eagerlyOneToMany PHP Метод

eagerlyOneToMany() защищенный Метод

一对多 关联模型预查询
protected eagerlyOneToMany ( object $model, array $where, string $relation, string $subRelation = '', boolean $closure = false ) : array
$model object 关联模型对象
$where array 关联预查询条件
$relation string 关联名
$subRelation string 子关联
$closure boolean
Результат array
    protected function eagerlyOneToMany($model, $where, $relation, $subRelation = '', $closure = false)
    {
        $foreignKey = $this->foreignKey;
        // 预载入关联查询 支持嵌套预载入
        if ($closure) {
            call_user_func_array($closure, [&$model]);
        }
        $list = $model->where($where)->with($subRelation)->select();
        // 组装模型数据
        $data = [];
        foreach ($list as $set) {
            $data[$set->{$foreignKey}][] = $set;
        }
        return $data;
    }