Home > front end >  how to pass variable from one blade to another blade in laravel
how to pass variable from one blade to another blade in laravel

Time:11-02

I want to pass value from order blade to receipt blade. But getting error in order.blade.php

order controller

$var['1'] = 'hello';
$var['2'] = 'hello2';

return \Redirect::back()->with([

      'print' => 1,
      'var'=> $var

     ]);

order blade

<div >
     @include('orders.receipt', ['data' => $session['var']])                  
</div>

receipt blade

<td ><p >{{ session('var.1') }}</p></td>

Getting error

Undefined variable: session (View: E:\xampp\htdocs\pos\resources\views\orders\order.blade.php)

Anybody help please?

CodePudding user response:

You can access the data inside the order.blade.php with Session::get('var');

After that, you can access the defined data inside receipt.blade.php with the $data variable.

  • Related