3 years ago

DRY repositories interfaces

Posted 3 years ago by jorgejavierleon

Hi. I have some doubts about my repositories design. I want to code to an interface all my repositories (although I don’t see myself swapping eloquent any time soon, I want to do that mostly for making my testing easier and to respect the SOLID principles ).

So, for my User model I will have a UserRepositoryInterface and then a DbUserRepository

Also, to avoid duplication, DbUserRepository it’s going to extend and abstract DbBaseRepository with common eloquent methods, all(), find(), etc.

Now, the problem I see is that, even with the abstract DbBaseRepository, I still need to duplicate mostly the same code for all my interfaces. I surely don’t want to do that.

Am I missing something here? Should I have a BaseInterface as well for all my interfaces?

Do you have any recommendations?

Please sign in or create an account to participate in this conversation.