public function hasOne($related, $foreignKey = null) { $foreignKey = $foreignKey ?: $this->getForeignKey(); $instance = new $related(); return new HasOne($instance->newQuery(), $this, $foreignKey); }