think\Model::hasManyThrough PHP Method

hasManyThrough() public method

HAS MANY 远程关联定义
public hasManyThrough ( string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', array $alias = [] ) : Relation
$model string 模型名
$through string 中间模型名
$foreignKey string 关联外键
$throughKey string 关联外键
$localKey string 关联主键
$alias array 别名定义
return think\model\Relation
    public function hasManyThrough($model, $through, $foreignKey = '', $throughKey = '', $localKey = '', $alias = [])
    {
        // 记录当前关联信息
        $model = $this->parseModel($model);
        $through = $this->parseModel($through);
        $localKey = $localKey ?: $this->getPk();
        $foreignKey = $foreignKey ?: Loader::parseName($this->name) . '_id';
        $name = Loader::parseName(basename(str_replace('\\', '/', $through)));
        $throughKey = $throughKey ?: $name . '_id';
        return $this->relation()->hasManyThrough($model, $through, $foreignKey, $throughKey, $localKey, $alias);
    }