How to pass data from controller to view in Laravel

Last Updated: October 19, 2020

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);
}