How to pass data from controller to view in Laravel

March 10, 2018

You can use the following code to pass to data from Laravel controller to the view

public function index(){
     $memberships = Membership::all();
     return view('membership.index')->with("memberships",$memberships);
}