The repository pattern is a bit controversial on how it is being used in Laravel projects. In this article, we will revisit the state of the art of the repository pattern with its pros and cons.
To use a repository pattern, you will need to have interfaces and a concrete implementation for each storage layer. The following is an example of such implementation, diagram Repository pattern Implementation exampleNote: in the above example, we have a separate repository for accessing data through cache (BookCacheRepository).
While researching this article, I came across many examples of the repository pattern in Laravel.