Support the ongoing development of Laravel.io →
Database Eloquent Architecture
Last updated 2 years ago.
0

That doesn't allow for simultaneous use of both repositories, does it?

Last updated 2 years ago.
0

Still interested if anyone has any thoughts about this.

Last updated 2 years ago.
0

So, if I'm understanding the problem correctly, you have a single entity that is pulling data from multiple places, not just tables but different DBs. In my opinion, you need two things:

  1. A single entity class that contains all of this data, plus whatever business logic makes sense
  2. A repository class that can map the entity's data to its multiple sources

The downside is that you won't be able to use Eloquent for this, or at least if you tried it would be very hacky and brittle. And your repository logic is going to be somewhat complex since you're building the entity from multiple data sources. But, at the end of the day isolating that complexity in your repository implementation is the most robust and maintainable way to do it.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

beaverusiv beaverusiv Joined 10 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.