I am trying to dynamically populate an invoice(wrapper for DomPDF) with jquery dynamically generated invoice. First of all on a different page saving the inputs to sessions and with a "redirect to" the invoice page generate the invoice. Long story short i have this to put the values
Session::put('invoice-data1', post('product'));
Session::put('invoice-data2', post('qty'));
Session::put('invoice-data3', post('price'));
Session::put('invoice-data4', post('total'));
Session::put('invoice-data5', post('sub_total'));
Session::put('invoice-data6', post('tax_amount'));
Session::put('invoice-data7', post('total_amount'));
return Redirect::to('invoice');
fields like product, price, qty are this way in the input field expecting an array
<input type="text" name="product[]" />
and then to get the the session value in the invoice page i have
$product = Session::pull('invoice-data1');
$qty = Session::pull('invoice-data2');
$price = Session::pull('invoice-data3');
$total = Session::pull('invoice-data4');
$subTotal = Session::pull('invoice-data5');
$taxAmount = Session::pull('invoice-data6');
$totalAmount = Session::pull('invoice-data7');
$templateCode = 'renatio::invoice'; // unique code of the template
$data = [
'product' => $product,
'qty' => $qty,
'price' => $price,
'total' => $total,
'subTotal' => $subTotal,
'taxAmount' => $taxAmount,
'totalAmount' => $totalAmount
]; // optional data used in template
return PDF::loadTemplate($templateCode, $data)->stream('download.pdf');
Trying it with just a regular input field works without an issue but this way it throws up an error of
"Array to string conversion"
A little confused how to get the session in my php code or in twig which i am using