Closed genyded closed 4 years ago
OK, figured this out. We moved the DB change into the relationship on the actual Model (where is probably should be). We just can't eager load in JSON API for the index methods and it all seems to work as expected. Closing this.
Great glad you got it sorted!
Our app is multi-tenant and we have some related tables in a tenant specific database. We have middleware that toggle it when the route has a {record}, but when get include or related data for the parent collection, only the first one has the data.
When using Laravel API resources, we can set it on the parent resource in the toArray method. We tried it in you code in the Schema's get Relationship method, but it does not seem to have any impact:
We can dd and set it gets set, but the relationships are still going to the wrong DB. Where should we set something like this for your code?
TIA!