I have a very specific situation regarding databases in Laravel. We have two DIFFERENT servers, one with SQL SERVER and one MySQL.
The regular join (belongsTo, hasMany) between two different connections and different servers is working flawlessly and I can get all the data that I want.
The problem occurs when I want to add WHERE
parameters to the relationship - Laravel will add subquery "and exists"
into the query - which will, of course, fail because we have two different servers.
Both models have correction table and connection specified in model properties and as I said regular belongsTo and hasMany is returning the correct results from both servers. Only WHERE conditions are failing the query.
What are the ways to solve this problem and how do you usually deal with this?
Much appreciated!
where
method on relationship model and overload the required code. Eventually I believe you could use laravel mutators as well to query the database specifically for one custom attribute: laravel.com/docs/master/eloquent-mutators – user8555937