在Laravel中插入多行 [英] Insert multiple rows in Laravel

查看:96
本文介绍了在Laravel中插入多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Laravel的新手.只是绕开了MVC的想法.

I'm very new to Laravel. Just getting around the MVC idea.

我该如何使用Laravel进行编写,以便可以在数据库中插入/更新多行?对于一个条目,如果我写错了,请纠正我,我可以在View中编写表单,该表单的内容基于我的Controller创建函数"显示(例如,在哪里收集数据以输入到我的Select表单输入中),然后在模型中检查我的数据,并将其返回到我的控制器存储"并保存.

How would I go about writing in Laravel so I can insert / update multiple rows into my database? For one entry, correct me if I'm wrong, I can write my form in a View, which the content are shown based on my Controller 'create function' (e.g. where to gather data to input into my Select form input), it then checks my data in the Model and returns it to my Controller 'store' and saves it.

如何通过存储功能将数据传递到数据库?如何在一页上写三到四遍表单(内容相同,例如project_detail,project_name,project_price).如何传递数组,以便每个数组都作为新行输入?

How does the data get passed to the database in the store function? How would I go about writing a form (same content - e.g. project_detail, project_name, project_price ) three or fours times, on one page. How do I pass the arrays so each array gets entered as a new row?

推荐答案

我认为您正在尝试创建购物车类型的功能.

I think you're trying to create a shopping cart type functionality.

您可以只创建一个表单来添加项目.然后创建一个表格,其中会列出您添加的项目.您可以使用ajax提交表单.然后将项目存储在会话中.或者您可以使用购物车套餐.然后将添加的项目显示到视图中.

You can just create a single form to add items. then create a table that would list the items you've added. you can use ajax to submit your form. then store the items in a session. or you can use shopping car package. then display the added items to your view.

希望这使您对如何进行项目有所了解.

hope this gives you a little idea how to go about with your project.

这篇关于在Laravel中插入多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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