沃梦达 / 编程问答 / php问题 / 正文

Laravel 3:寻找如何使用模型的解释

Laravel 3 : Looking for explanation how to use the model(Laravel 3:寻找如何使用模型的解释)

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

问题描述

我是 MVC 的新手,我的第一个框架是 Laravel(现在是 3 个).我已经开始专门在路由中编码,然后我转向了控制器.但是,我正在控制器中执行所有数据库操作.我不明白如何使用模型.

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

谁能告诉我如何使用该模型?简而言之,我不明白如何将它们相互链接,例如将表单输入发送到它们的模型,或将处理后的数据发送回控制器.

具有完整 MVC 设置的 Laravel(如果可能,v3)的 github 存储库也可以很好地分析,如果有人有一个给我看?

谢谢.

解决方案

我听过的关于框架主题的最佳陈述归功于鲍勃叔叔:

<块引用>

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

特别是:

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

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

<块引用>

MVC 不是架构!这是一种交付设计模式.

观看他的视频 - 可悲的是,它是为数不多的没有花 1000 字来说明 10 中可以说的内容的视频之一,我不能高度推荐它 - 它会帮助您理解很多要点在您的问题中提出:

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

当然,他的《Clean Code》一书也值得推荐!

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:寻找如何使用模型的解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Laravel 3:寻找如何使用模型的解释

基础教程推荐