Laravel 中 resource.create 和 resource.store 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26958137/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel difference between resource.create and resource.store
提问by user2722667
I am about to learn about building RestFul apps in Laravel but I dont understand the difference between resource.createand resource.store
我即将学习在 Laravel 中构建 RestFul 应用程序,但我不明白resource.create和resource.store之间的区别
If I want to register and create a new user, does it then use resource.createor resource.store?
如果我想注册并创建一个新用户,它是使用resource.create还是resource.store?
If not, when to use resource.create? And when should I use resource.store?
如果没有,什么时候使用resource.create?我什么时候应该使用resource.store?
Cheers,
干杯,
回答by itachi
just a simple example. (oversimplification)
只是一个简单的例子。(过度简化)
let's say you are writing a blog.
假设您正在写博客。
the GET
request you are sending to get the form (where you will write the blog) is resource.create
.
GET
您为获取表单(您将在其中撰写博客)而发送的请求是resource.create
.
after finishing the writing, when you will submit and POST
the content so that it gets saved in somewhere, it is resource.store
完成写作后,当您提交POST
内容并将其保存在某个地方时,它是resource.store
in your case,
在你的情况下,
registration form
is resource.create
.
registration form
是resource.create
。
saving the info (submitting the form) is resource.store
.
保存信息(提交表格)是resource.store
.
回答by MANOJ
resource.create
shows the form for creating a new resource (front end only to show the form) and resource.store
stores a newly created resource in storage (db interaction to store the data).
resource.create
显示用于创建新资源的表单(前端仅显示表单)并将resource.store
新创建的资源存储在存储中(db交互以存储数据)。