So I've been reading Eric Evans' Domain Driven Design book and there is a part there where he talks about repositories and aggregates stating that if you need to access children of an aggregate you should access it through the aggregate root by traversal. So for example we have a Store application and we have three models, Customer, Order, and Product. The relationship between these models would be Customer has many Order and Order has may Product. We also decided that root of the aggregate would be Customer so we decide to create a CustomerRepository class. Now this CustomerRepository class would need to provide you a Customer model where you could access all of its Order and the Products within each Order. Using Eloquent that would be easy since you would just need to setup the relationship, but in our case we wouldn't be using Eloquent, our data would be coming from an external REST API server where they have provided three REST URL's for us to use,
customer/[customer_id] - for fetching the customer details but does not include the orders order/[customer_id] - for fetching the details of the orders but does not include the products of a specified customer product/[order_id] - for fetching the products within an order
Does this mean inside my CustomerRepository::findById function, I would need to make use of those three REST URL's to build a Customer model complete with Orders and Products? How would you guys handle this situation?
Thank you, Sherwin