I am working with a Laravel project and I am looking for a way to solve the issue of bloated models and cross referencing between them.
I had started extracting higher level methods to a repository but this doesn't solve the issue of one method needing to know about another method.
For example a task lookup method needs to lookup a slug in another table first. I don't believe I should be placing this code into either model or repository but i'd like a single method to achieve this lookup.
/Models/Slug /Models/Task /Repositories/SlugRepository /Repositories/TaskRepository
I have now started experimenting with adding a gateway/service layer with a higher level methods which can access both of the underlying repositories to complete the task.
The task service would depend on the two repositories above.
I think this will work but I am not sure if I should now let the controllers still access the repository directly or force everything through the service/gateway layer.
Or perhaps do away with the repositories entirely and let the services access the models directly, (Laravel abstracts db access anyway).
And on top of it all I want to keep this as simple as possible!
Can anyone confirm this method as a good choice or not or perhaps suggest an alternative?