re: The best Laravel repositories solution in 30 lines of code VIEW POST

FULL DISCUSSION
 

Using a repository class is a good example of the SRP (Single Responsibility Principle). But the real power is when your repository is not tightly coupled to your backend implementation (Eloquent).

 

I’m not sure power is the right word for this. I agree that your code will be better separated when you don’t use eloquent in combination with a repository but I’ve tried a couple repository packages for Laravel which all provide some methods for basic usage. The amount of code I had to write for the options I wanted was too much for me and more of a disadvantage than advantage. Eloquent is such a great tool and it felt like I abandoned it. That’s why I came up with this.

 

If Eloquent is the only thing you are going to need, then this works very well indeed. It becomes another matter if you anticipate changing your backend.

code of conduct - report abuse