Yes, you can specify the connection on each model, so you can create several model, and use eloquent relations to retrieve data from multiple databases.
Feb 13, 2019
2
Level 17
Two different databases on same query
Hello everyone,
I learned a nice trick from one of our members here where you can use a connection like this when you have multiple databases used in Laravel.
DB::connection('conn_2')->select(...)
However, I came to a scenario where I need to use two connections on the same query.
Something like this;
SELECT * FROM conn_1.db.users JOIN conn_2.db.user_rights on ...
Is there any way I can use two connections on the same query? Maybe I can create two models and then try that way.
Level 20
Please or to participate in this conversation.