think\Model::hasOne PHP Method

hasOne() public method

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