Hi!
I have multiple connection set at config/[login to view URL], defaultconnection is <connection1>, and other <connection2> etc etc...
Database are same names, so default connections database is connection1, and etc etc...
I have two models:
Model Reservations [login to view URL]
Model Customers [login to view URL]
Testing:
[login to view URL]
Code finds reservations and connect is right, but if try use method customer, not find customers, because laravel try find table customers from connection1's database instead of connection2's database. So if i move customers table to connection1 database, it works and code show me at var_dump($res->customer) connection is NULL. So Laravel lost connection at this method.
I have already tried:
- use setConnection instead of Reservations::on('connection2')
- set Connection inside of customer method
Any Ideas? I have multiple database with same names tables for different companys, so I can't set connection at model protected variable.
BEFORE YOU MAKE BIDS:
I give you only:
- Table structures, maybe example data
- Test Code
- Info about my connectios
- Models for Customers and Reservations
I CAN'T GIVE YOU ACCESS TO MY SERVER.
And result have work like is reading at Laravel's Eloquent documentation section belongsTo method. In same foreach-loop I need reservation and customer information working not different loops.