mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-09 01:27:20 +08:00
Fixes issue #1063: Fatal Error while getting value from ActiveRelation generated by Gii
This commit is contained in:
committed by
gudz.taras@gmail.com
parent
c5801dc659
commit
9c5ba231a1
@ -265,8 +265,8 @@ 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);",
|
||||
$refClassName,
|
||||
"return \$this->hasOne('$this->ns\\$refClassName', $link);",
|
||||
$this->ns . '\\' . $refClassName,
|
||||
false,
|
||||
];
|
||||
|
||||
@ -281,8 +281,8 @@ 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);",
|
||||
$className,
|
||||
"return \$this->" . ($hasMany ? 'hasMany' : 'hasOne') . "('$this->ns\\$className', $link);",
|
||||
$this->ns . '\\' . $className,
|
||||
$hasMany,
|
||||
];
|
||||
}
|
||||
@ -299,8 +299,8 @@ 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);",
|
||||
$className0,
|
||||
"return \$this->hasMany('$this->ns\\$className1', $link)->viaTable('{$table->name}', $viaLink);",
|
||||
$this->ns . '\\' . $className0,
|
||||
true,
|
||||
];
|
||||
|
||||
@ -308,8 +308,8 @@ 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);",
|
||||
$className1,
|
||||
"return \$this->hasMany('$this->ns\\$className0', $link)->viaTable('{$table->name}', $viaLink);",
|
||||
$this->ns . '\\' . $className1,
|
||||
true,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user