Support the ongoing development of Laravel.io →
Architecture
Last updated 2 years ago.
0

The examples like you mentioned are used in Laravel screencasts, so I guess it's not a bad practice.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.