think\Model::belongsTo PHP Method

belongsTo() public method

BELONGS TO 关联定义
public belongsTo ( string $model, string $foreignKey = '', string $otherKey = '', array $alias = [], string $joinType = 'INNER' ) : Relation
$model string 模型名
$foreignKey string 关联外键
$otherKey string 关联主键
$alias array 别名定义
$joinType string JOIN类型
return think\model\Relation
    public function belongsTo($model, $foreignKey = '', $otherKey = '', $alias = [], $joinType = 'INNER')
    {
        // 记录当前关联信息
        $model = $this->parseModel($model);
        $foreignKey = $foreignKey ?: Loader::parseName(basename(str_replace('\\', '/', $model))) . '_id';
        $otherKey = $otherKey ?: (new $model())->getPk();
        return $this->relation()->belongsTo($model, $foreignKey, $otherKey, $alias, $joinType);
    }