mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00
Replaces commit dfcf037c7. The prvious idea was wrong and broke some tests
This commit is contained in:
@ -772,11 +772,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
*/
|
||||
public function viaTable($tableName, $link, callable $callable = null)
|
||||
{
|
||||
if ($this->primaryModel === null) {
|
||||
throw new InvalidConfigException('The "primaryModel" property is not set. The query must be a relation to use junction tables. You probably need to call hasOne() or hasMany() method first.');
|
||||
}
|
||||
|
||||
$modelClass = get_class($this->primaryModel);
|
||||
$modelClass = $this->primaryModel ? get_class($this->primaryModel) : $this->modelClass;
|
||||
$relation = new self($modelClass, [
|
||||
'from' => [$tableName],
|
||||
'link' => $link,
|
||||
|
Reference in New Issue
Block a user