Implement Repository Pattern in Laravel

preview_player
Показать описание
In this tutorial we will see why it is a bad idea to call the eloquent model directly in the controller, while we could implement a repository to handle all the logic related to the database and remove the code coupling to the laravel framework.

In addition we will also see how to inject the logger service and use it instead of calling the laravel Facades.

Рекомендации по теме
Комментарии
Автор

Hi @O'Brant, thanks for the video, I however have some recommendations. The UserRepository type used in the controller should actually be a RepositoryInterface. It would actually be great to instead even have a UserRepositoryInterface, that way, other models and such in a big project can each have it's own repository interface. Now, with all these interfaces, a controller should only make reference to the interface so that the IoC will be responsible for binding the interface to the concrete implementation at the time when it is called, given certain conditions. This can be handled in or you could simply create your own service provider which can be configured in config/app . Good tutorial by the way.

RichardOpokuEngineer
Автор

Hi, i am get this error
message: "Interface not found"

i have follow your steps but getting the above error, please help how to solve ?

soorajking