Corcel\Model::hasOne PHP Method

hasOne() public method

Replace the original hasOne function to forward the connection name
public hasOne ( string $related, null $foreignKey = null, null $localKey = null ) : Illuminate\Database\Eloquent\Relations\HasOne
$related string
$foreignKey null
$localKey null
return Illuminate\Database\Eloquent\Relations\HasOne
    public function hasOne($related, $foreignKey = null, $localKey = null)
    {
        $foreignKey = $foreignKey ?: $this->getForeignKey();
        $instance = new $related();
        if ($instance instanceof Model) {
            $instance->setConnection($this->getConnection()->getName());
        } else {
            $instance->setConnection($instance->getConnection()->getName());
        }
        $localKey = $localKey ?: $this->getKeyName();
        return new HasOne($instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey);
    }