How to pass data from controller to view in Laravel
Last Updated: February 27, 2022
You can use the following code to pass data from the Laravel controller to the view
public function index(){ $memberships = Membership::all(); return view('membership.index')->with("memberships",$memberships); }
Otherways to pass data to view
return View::make("user/regprofile", compact('students')); OR
return View::make("user/regprofile")->with(array('students'=>$students));