Skip to content

Commit

Permalink
Update Generator.php
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagotalma committed Oct 17, 2023
1 parent 752717e commit 3002fb2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/generators/model/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,14 +682,15 @@ protected function generateRelations()
// Foreign key could point to non-existing table: https://github.com/yiisoft/yii2-gii/issues/34
continue;
}
$relName = $refs[0];
unset($refs[0]);
$fks = array_keys($refs);
$refClassName = $this->generateClassName($refTable);
$refClassNameResolution = $this->generateClassNameResolution($refClassName);

// Add relation for this table
$link = $this->generateRelationLink(array_flip($refs));
$relationName = $this->generateRelationName($relations, $table, $fks[0], false);
$relationName = $this->generateRelationName($relations, $table, $relName, false);
$relations[$table->fullName][$relationName] = [
"return \$this->hasOne($refClassNameResolution, $link);",
$refClassName,
Expand Down

0 comments on commit 3002fb2

Please sign in to comment.