I have a table which is Order
and Product
- orders table: id, order_name
- products table: id, orders_id, product_name
In my model:
Order
can have many products
.
Product
belongs to order
Below is my view:
<input type="text" name="order_name">
<input type="text" name="product_name">
<input type="text" name="order_name">
<input type="text" name="product_name">
From the view above, I have two forms whereby the users can add two form with two input.
Now my problem is how do I write the logic in the controller?
I just know the way to write insert one order with multiple product. But I don't know how to insert multiple orders with its related product.