MVC pattern combined with Repository pattern in Laravel?

81 views Asked by At

So far I understand, a repository pattern contains the methods to save data in the database. It is useful to encapsulate this access to the database from the other parts of the business logic.

A Model, also a part to handle the access to the DB and prepare date before they where send or stored.

If I combine both, so I will use a repository in a model, I've a segregation of preparing the data and access to the DB.

Is this a good to follow this concept in Laravel? In Laravel I can execute the methods like orderBy(...), all() and where(...) in the model.

Or is the assumption correct, that the model is just the data layer for the Controller? Should I use the Model only for purpose of the Controller and the repository for all other stuff of using data.

0

There are 0 answers