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

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

BELONGS TO MANY 关联查询
protected belongsToManyQuery ( object $model, string $table, string $foreignKey, string $localKey, array $condition = [] ) : Query | string
$model object 关联模型对象
$table string 中间表名
$foreignKey string 关联模型关联键
$localKey string 当前模型关联键
$condition array 关联查询条件
Результат Think\Db\Query | string
    protected function belongsToManyQuery($model, $table, $foreignKey, $localKey, $condition = [])
    {
        // 关联查询封装
        $tableName = $model->getTable();
        $relationFk = $model->getPk();
        return $model::field($tableName . '.*')->field(true, false, $table, 'pivot', 'pivot__')->join($table . ' pivot', 'pivot.' . $foreignKey . '=' . $tableName . '.' . $relationFk)->where($condition);
    }