|
|
@@ -181,16 +181,20 @@ class BelongsToMany extends Association {
|
|
|
}
|
|
|
|
|
|
if (!$target->association($junctionAlias)) {
|
|
|
+ $target->hasMany($junctionAlias, [
|
|
|
+ 'targetTable' => $table,
|
|
|
+ 'foreignKey' => $this->targetForeignKey(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$target->association($sAlias)) {
|
|
|
$target->belongsToMany($sAlias, [
|
|
|
- 'sourceTable' => $source,
|
|
|
+ 'sourceTable' => $target,
|
|
|
+ 'targetTable' => $source,
|
|
|
'foreignKey' => $this->targetForeignKey(),
|
|
|
'targetForeignKey' => $this->foreignKey(),
|
|
|
'through' => $table
|
|
|
]);
|
|
|
- $target->hasMany($junctionAlias, [
|
|
|
- 'targetTable' => $table,
|
|
|
- 'foreignKey' => $this->targetForeignKey(),
|
|
|
- ]);
|
|
|
}
|
|
|
|
|
|
if (!$source->association($table->alias())) {
|