Multiple database connection for join tables


#1

I’m using
static get connection() {
return ‘mysql1’
}
method in Model to use different database. While creating a record in main table it is working properly but while creating the record in join table it is not working and it shows error as there is no join table in the default database. How to create join table record in different database connection. Thanks in advance.


#2

Can you share the proper code for the Models you are using and the how you creating the join?


#3

Thanks for your interest in my query. And i have sorted it out. Th above issue was solved by using pivotmodel option in belongsToMany mapping.


#4

When asking question and solving please share on how you’ve managed that so the other users experiencing the same issue as you did, can find this post and take a look at the example you provided.