Insert multiple rows in Laravel

878 views Asked by At

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

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.

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?

1

There are 1 answers

2
dakine On

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

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.