Closed denitsa-md closed 3 years ago
I actually just noticed we have a few classes extending the base repos but none of the functionality was used. So I removed it as a dependency entirely.
I'm just curious about your opinion on it being an anti-pattern 🙂
Laravel is, by design, set up to detach your database, storage, caching, etc. solutions from your client code. Eloquent is an example of this: you could be storing the same models in SQLite, MySQL, etc. For most projects it is extremely unlikely that you will ever want to switch out for something that Eloquent does not support. And if you do, why not use Symfony, or a custom storage solution in the first place?
So that doesn't seem to me to warrant the increased complexity of a repository layer.
Another consideration is that Eloquent is an active record solution. This does not jive well with the repository pattern, as Eloquent models are their own repositories, as it were. If you do not like this, Doctrine is a much better solution for you; if you do like it, why wrap it in an extra layer of complexity?
Feature consideration: the extra features provided by this package (caching, criteria) are overly complicated and don't suit the typical Laravel project. For projects where they are good, I'd (now) recommend using query objects and Eloquent traits/plugins instead.
And finally: if you do want to group complex queries in a repository class, I'm still in favour of that in some situations -- but you don't need a package for this. It'd be fine as just a class that performs the queries, accesses query objects, caching, etc. But I'm pretty sure that anyone who needs this kind of thing is also able to do a much better job than this package makes of it! :D
Thank you for the answer. Agree as well. I tend to add a query object wherever I need a more complex or reusable query
Hey @czim @denitsa-md
I think this is fixed by #17. And can be closed.
Honestly, I'm surprised people still use this! It's such an anti-pattern, especially the way this package is implemented. I'd never even considered it as upgrade-worthy.
I'll decide soon whether I'll deprecate/abandon this, or whether I'll work on one more upgrade. If someone wants to take over this package, be my guest! If not, I'm open to suggestions -- and I'm also all ears if anyone still thinks this package is worth salvaging.