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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:25:59  来源:igfitidea点击:

Laravel difference between resource.create and resource.store

phpapirestlaravel

提问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.createresource.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 GETrequest 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 POSTthe content so that it gets saved in somewhere, it is resource.store

完成写作后,当您提交POST内容并将其保存在某个地方时,它是resource.store

in your case,

在你的情况下,

registration formis resource.create.

registration formresource.create

saving the info (submitting the form) is resource.store.

保存信息(提交表格)是resource.store.

回答by MANOJ

resource.createshows the form for creating a new resource (front end only to show the form) and resource.storestores a newly created resource in storage (db interaction to store the data).

resource.create显示用于创建新资源的表单(前端仅显示表单)并将resource.store新创建的资源存储在存储中(db交互以存储数据)。