Home > OS >  Is it good practice to create Models directory?
Is it good practice to create Models directory?

Time:11-17

By default, Laravel's model classes are placed in the App/ directory and models files mess up the App/ directory. So, I want to create an App/Models/ directory and move all model classes to App/Models/.

And there are many articles in the internet and stackoverflow answers about how to do that.

My question is whether it is a good practice or bad practice to move models to App/Models/ in Laravel?

Laravel doesn't do it by default, so I think it should be a very bad practice because it is said that Laravel gives developers the best practices, and I'm afraid that moving models to App/Models/ causes troubles in the future while developing.

If it is a good practice, why doesn't Laravel do it by default?

CodePudding user response:

That is not quite right. Since Laravel 8, the models can be found under App/Models. And I think it's better that way.

CodePudding user response:

It is completely okay to do like that. Always I create separate folders for Frontend, backend controllers also. In Models also you can do as per you wish. Only thing is you have to define namespace depend on that.

  • Related