I Want To Send Data From One View To Another Laravel View

- 1 answer

i have two views, view-1 and view-2.

  • view-1 has form, which will store data temporary.
  • i want to get data from view-1 and send it to view-2, which has user profile, where temporary data from view-1 will be shown.
  • how we can achieve it in Laravel, i know we can store data in SQL and then fetch it, but how to do it without storing to SQL.

my code: view: 1

<form >
  <div class="form-group">
    <label class="col-form-label" >Date</label>
    <input type="text" name="sdate" class="form-control">
    <input type="submit"  class="btn btn-primary" value="Add date" >

view 2 Controller:

public function report2($id)
$teacher = Teacher::teacher($id);
return View('teachers.report2' ,compact('teacher','today','sdate'));


Route::get('teachers/{id}/report2', '[email protected]');


Use session, for example in view1 you pass variable of date do this on your controller of view 1

session(['sdate' => $request->sdate]);

and then you can get the value of the session in your controller or view by calling this

$date = session('sdate');

further reading see the docs