Hi, I guess the idea of model repositories came from doctrine repositories? But I don't actually get what is the advantage of using it in laravel-eloquent?
If at a certain point of your development you decide to move from eloquent to fluent or other systems you won't need to touch your controllers and eventually the tests you've prepared for your application
luknei said:
Hi, I guess the idea of model repositories came from doctrine repositories? But I don't actually get what is the advantage of using it in laravel-eloquent?
luknei said:
Hi, I guess the idea of model repositories came from doctrine repositories? But I don't actually get what is the advantage of using it in laravel-eloquent?
what @spescina said but I think it's a better separation of your code. your controllers models should be as lean as possible and you repositories can be used in multiple stages of your app.
if you need to get the user's posts throughout your app you don't need to add where('user', $userid)
in every controller method, you do this once in your repository and then use your repository in your controller
Well I get your point. I am trying to prevent builing custom query methods inside my controller to keep them as clean as possible. I am using reposinotories at work, where we use zend fw 2 + doctrine 2, since entities are quite long, there are a lot of properties and setters/getters :) Currently, I do not see the need to do this in eloquent models, because with all the necessary properties and ardent my models are up to 50 lines of code so I put my scope methods into the model class :)
Hi Zenry,
Not sure if this blog is what I'm looking for, but the site is down. I'm looking for an example on how to use doctrine. I'm new to both doctrine and Laravel.
thanks in advance,
Dave
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community