Laravel 5.5
I've got two models, User and Conversation
User to Conversations is a many to many relationship (both ways).
My table structure is as follows:
conversation is on database_1
conversation_user is on database_1
user is on database_2
Inside App\Conversation.php:
protected $connection = 'database_1';
protected $table = 'conversations';
public function users()
{
return $this->belongsToMany("App\User");
}
Inside App\User.php:
protected $connection = 'database_2';
protected $table = 'users';
public function conversations()
{
return $this->belongsToMany("App\Conversation");
}
All of this is on the same server but is there a way to have this working or not ?
When querying the relationship on Conversation to get users, it's looking for database_2.conversation_user instead of database_1.conversation_user
So in essence, I need to say that the Pivot table is located in database_1, is there a way to do this?