Slide 7
Slide 7 text
REPOSITORIES IN LARAVEL
According to Wikipedia, a repository commonly refers to a storage location, often for
safety or preservation. In Laravel, repositories act as both a factory and a collection
store which filter and transform data units. This is made possible because
repositories are powered by ORMs (Doctrine / Eloquent) making it possible to
hide/abstract complex implementation details for database queries.
In a multi-layered architecture, repositories belong to the application-service layer.
Repositories should be completely isolated (i.e. loosely coupled) from the details of
the business logic (which reside in the domain layer) using the SOLID pattern
popularized by Robert C. Martin (Uncle Bob).
Repositories should have singular tasks (i.e. they do one thing only). They should
have at most one Model (in an MVC setting). When you require to use more than
one model (e.g. for join queries), you should use a decorator.
Repositories should only be instantiated as singletons and never in any other way.