Laravel 5.1 relationship with multiple database

549 Views Asked by At

I am using Laravel5.1 with MongoDB in my application.

I have one default database and separate databases for each user.

I want to use relationship between user seperate DB and default DB. I try it using protected $table = 'default_db_name.table_name'; and i also try the solution from this laravel forum.

http://laravel.io/forum/02-12-2014-many-to-many-relationship-not-working-across-databases.

The Laravel documentation and google dont seem to worked for me.

Any help greatly appreciated

1

There are 1 best solutions below

3
On

try https://github.com/jenssegers/laravel-mongodb

there you can connect to multiple servers

'mongodb' => array(
'driver'   => 'mongodb',
'host'     => array('server1', 'server2'),
'port'     => 27017,
'username' => 'username',
'password' => 'password',
'database' => 'database',
'options'  => array('replicaSet' => 'replicaSetName')

),