-1👍
In the Invoices controller after saving the Invoice you should use the Many to Many relationship to attach()
the item to the invoice here is how you do it .
public function store(Request $request)
{ $invoice = Invoice::create([
'invoice_no' => 'invoice',
'invoice_date'=> $request->input('invoice_date'),
'due_date'=> $request->input('due_date'),
'customer_id'=> $request->input('customer_id'),
'sub_total' => $request->input('sub_total'),
'discount' => $request->input('discount'),
'total' => $request->input('total')
]);
$item = Item::findOrFail($request->get('item_id'));
$item->invoices()->attach($invoice->primary_key, ['quantity' =>$request->get('quantity')]);
return redirect('/invoices');
}
- [Vuejs]-Show counts of drag items in VUE draggable for Nested Item List
- [Vuejs]-How to grab value from v-model by array
Source:stackexchange.com