The Repositories actually act as a bridge between controller and model, where you can write your business logic. Let’s say you need to Register a user for which you will write a code in Repository class, and link it with the controller to get access to it. Now the point is we cannot write business logic in controller neither in Model. The Model class will be responsible for getting and setting the data in database and while repository class manages the business logic. That’s pretty clean and manageable.
This extremely useful incase you are developing Mobile APIs as well as Admin and website using the same functionality / business logic, with this you dont need to write the core logic again and again, we just need different controllers for API, Admin, Web.
You might have noticed that i didn’t use abstract classes for implementation rather i used IoC (Inversion of control) for model dependency in repository class, you cannot use any other model in that repository.
Please give your thoughts on this structure how can we improve it.
Thanks for taking interest.