The examples like you mentioned are used in Laravel screencasts, so I guess it's not a bad practice.
If you want to use a repository pattern, then it's bad practice. But on topic, if your app is small it's not bad practice what you done there.
eriktisme said:
If you want to use a repository pattern, then it's bad practice. But on topic, if your app is small it's not bad practice what you done there.
Thanks, but it is worth time spent on repository pattern? What can you do with it if you won't plan to use anything else except mysql as database.
The code which you are using
public function index() {
return Model::find(1);
}
it is suitable if you are making a very small or a demo project where you need not worry about business validations, error handling, scalability etc.
As mentioned:
aik099 said:
The examples like you mentioned are used in Laravel screencasts, so I guess it's not a bad practice.
Laravel screen cast are purely for demo purposes, I would not suggest to use this code if you are building a large application where you need to deal with all sorts of complexities. Then it is advised to use some more flexible design pattern like Repository pattern, or you can develop one of you own based on your requirements. I would suggest to make you application abstract.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community