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

Well, I watched all of them earlier. I am new to MVC and Laravel. I will watch them again. So basically, this is what I understand.

All model and database queries must be done in the controller. And then pass the variables to the view from the controller.

Last updated 2 years ago.
0

Watch this http://vimeo.com/12643301

and read some of this guy's answers on SO: http://stackoverflow.com/questions/16356420/mvc-for-advanced-php-developers/16356866#answer-16356866

To be precise, what you are referring to is a template, not view. And yes, it is a bad practice, don't do that :)

Last updated 2 years ago.
0

Thank you. :)

Last updated 2 years ago.
0

Thank you. :)

Last updated 2 years ago.
0

Theres a lot of "watch this video" type responses here =)

I'm pretty new to Laravel but I have pretty extensive experience with codeigniter and a fairly thorough understanding of the MVC and these are my thought:

Though possible it isn't a good idea to call a model or directly query from the view. A core benefit of the MVC architecture is the ability to separate your data, logic and view/template from one another. Doing this allows your models, views, and controller to focus on doing one thing (ie: query the DB, get the data from the DB and apply some logic on it, build a template your users will see, etc...) and usually that one thing that is done is done well.

Another benefit of having that one thing do that one job is code maintainability. Weeks/months down the line when you're back editing this code again (because you will, we all do) you won't be scratching your head asking yourself why you put a database query into your view.

Last updated 2 years ago.
0

In the video I linked Uncle Bob talks>zakiaziz said:

Another benefit of having that one thing do that one job is code maintainability. Weeks/months down the line when you're back editing this code again (because you will, we all do) you won't be scratching your head asking yourself why you put a database query into your view.

This is what Uncle Bob presents in that video I linked, and this is why it was linked in the first place.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

drtechie drtechie Joined 8 Aug 2014

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.