Commit f63720c6 by Qiang Xue

Merge pull request #1068 from nukkumatti/master

Fixes issue #1063: Fatal Error while getting value from ActiveRelation g...
parents c5801dc6 5b1ba04a
......@@ -265,7 +265,7 @@ class Generator extends \yii\gii\Generator
$link = $this->generateRelationLink(array_flip($refs));
$relationName = $this->generateRelationName($relations, $className, $table, $fks[0], false);
$relations[$className][$relationName] = [
"return \$this->hasOne('$refClassName', $link);",
"return \$this->hasOne($refClassName::className(), $link);",
$refClassName,
false,
];
......@@ -281,7 +281,7 @@ class Generator extends \yii\gii\Generator
$link = $this->generateRelationLink($refs);
$relationName = $this->generateRelationName($relations, $refClassName, $refTable, $className, $hasMany);
$relations[$refClassName][$relationName] = [
"return \$this->" . ($hasMany ? 'hasMany' : 'hasOne') . "('$className', $link);",
"return \$this->" . ($hasMany ? 'hasMany' : 'hasOne') . "($refClassName::className(), $link);",
$className,
$hasMany,
];
......@@ -299,7 +299,7 @@ class Generator extends \yii\gii\Generator
$viaLink = $this->generateRelationLink([$table->primaryKey[0] => $fks[$table->primaryKey[0]][1]]);
$relationName = $this->generateRelationName($relations, $className0, $db->getTableSchema($table0), $table->primaryKey[1], true);
$relations[$className0][$relationName] = [
"return \$this->hasMany('$className1', $link)->viaTable('{$table->name}', $viaLink);",
"return \$this->hasMany($className1::className(), $link)->viaTable('{$table->name}', $viaLink);",
$className0,
true,
];
......@@ -308,7 +308,7 @@ class Generator extends \yii\gii\Generator
$viaLink = $this->generateRelationLink([$table->primaryKey[1] => $fks[$table->primaryKey[1]][1]]);
$relationName = $this->generateRelationName($relations, $className1, $db->getTableSchema($table1), $table->primaryKey[0], true);
$relations[$className1][$relationName] = [
"return \$this->hasMany('$className0', $link)->viaTable('{$table->name}', $viaLink);",
"return \$this->hasMany($className0::className(), $link)->viaTable('{$table->name}', $viaLink);",
$className1,
true,
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment