Laravel 3:寻找解释如何使用模型 [英] Laravel 3 : Looking for explanation how to use the model

查看:47
本文介绍了Laravel 3:寻找解释如何使用模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MVC的新手,我的第一个框架是Laravel(目前为3).我已经开始专门在路线中进行编码,然后移至控制器.但是,我正在控制器中进行所有数据库操作.我不知道如何使用该模型.

示例演示了控制器或路径中的所有内容,但它们从未拆分模型,控制器和视图.

有人可以请我解释一下该模型的使用方法吗?简而言之,我不了解如何相互链接,例如将表单输入发送给他们模型,或将处理后的数据返回给控制器.

一个完整的MVC设置的Laravel(如果可能,则为v3)的github仓库也很容易分析,如果有人愿意找我看的话?

谢谢.

解决方案

关于我听说过的关于框架的最佳说法是鲍勃叔叔(Uncle Bob)

好的架构可以推迟重大决策!

特别是:

  • 好的架构会延迟选择框架!

另一个值得考虑的伟大作品:

MVC不是体系结构!这是一种交付设计模式.

观看他的视频-这是可悲的少数几个视频之一,它不花1000字来表达10个单词中的任何内容,我对此并不十分推荐-它将帮助您理解许多要点在您的问题中提出:

Robert C Martin(鲍勃叔叔)-清洁建筑与设计-视频

当然,强烈建议他写一本有关清洁代码"的书!

I'm new at MVC and my first framework is Laravel (3 for now). I've started coding exclusively in the routes, and I moved to the controller. I'm however doing all of my database operations in the controller. I do not understand how to use the model.

Examples either demonstrate everything in the controller or in the route, but they never split the model, controller and view.

Could anyone kindly explain me how to use the model? In short I don't understand how to link one to each other, like sending form input to them model, or processed data back to the controller.

A github repo of a Laravel (v3 if possible) with a full MVC setup would be nice to analyze too, if anyone has one up for me to look at?

Thanks.

解决方案

The best statement on the subject of Frameworks I've heard is due to Uncle Bob:

A good Architecture allows major decisions to be deferred!

Specifically:

  • A good Architecture delays choosing a Framework!

Another great piece to think about:

MVC is not an Architecture! It is a Delivery Design Pattern.

Watch his video - it is one of the sadly few ones out there that don't spend 1000 words on what can be said in 10 and I can't highly enough recommend it - and it will help you to understand many points raised in your question:

Robert C Martin(Uncle Bob) -Clean Architecture and Design - Video

Of course, his book on Clean Code is also highly recommended!

这篇关于Laravel 3:寻找解释如何使用模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆