Support multiple ManyToMany fields that are using the same junction table
kop opened this issue · comments
I have a model where I need to use ~10 ManyToMany fields that are using the same junction table but different additional field in junction table.
Current behaviour does not support such usage, because of this lines of code:
// Remove old relations
$connection->createCommand()
->delete($junctionTable, [$junctionColumn => $primaryModelPk])
->execute();
This code is located inside the foreach
, so each time new links are inserted to the junction table, it removes previous inserts.
This code block needs to be moved upper in the code, before foreach
even starts.