Laravel Repository Pattern with Example - (Coding best practices)

preview_player
Показать описание
Repository pattern is one of the ways to write scalable and maintainable codes in Laravel.

Learn how you can implement the repository pattern in your Laravel project, with an easy to understand example.
Рекомендации по теме
Комментарии
Автор

Concept wise nice explanation but the flow should be like
Route -> Controller (which returns JsonRespnse) -> Service (Returns Array) -> Repository (Returns Collection) Or Action (Returns Array)


So this is the best practice as I think.

dhavalmistry
Автор

the best tut i have ever seen at that topic :)

abdallahquapeel
Автор

Great job, this is really good content!

slablife
Автор

This a good example of the repository pattern. In my opinion, using the repository pattern with the active record pattern makes no sense, since it is returning instances of an active record model, and that leaks the database abstraction layer. In turn, the repository should return domain objects with state and methods, but the responsibility to persist or change data in the storage is of the repository. What prevents you to call an update method on a model returned by the repository? That's where things can get out of control.

uxweb
Автор

What if the datasource was determined my user input? How could you tell the system to use the QuoteRepo or the QuoteRepoFile from the index method?

CyanidePierce