Laravel Repositories

前端 未结 4 2128
野趣味
野趣味 2020-12-09 03:27

What are the advantages of Repositories in Laravel? It seems to be abstracting the Model layer from the business logic of the application. Although it really just seems to m

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 04:02

    The main reason you use repository pattern is to be able to easily change your data source. For example, in my experience the most common change is adding a caching layer, because the repository implements an interface all you need to do is build the new object implementing the same interface with the new methods handling cache and change the binding.

提交回复
热议问题