My table structure is like this:
invoices:
id, title, desciption, total_amount, --
products:
id, name, price, --
invoice_products
id, invoice_id, product_id, --
-
One invoice can have multiple products, so,
-
I created an invoice with products, then data fills according to above DB structure.
-
When i update invoice (let say invoice_id = 2 ), then, i am confused what is the best way to update "invoice_products" table.
-
My approach is ( for "invoice_products" table):
- delete * from invoice_products where invoice_id=2;
- then insert modified products again.
-
I think this is not good approach, as i am force deleting the rows in "invoice_products" and again inserting new updated products.
-
is there any way to do via eloquent ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire