How to pass data to view in Laravel?
You can pass data to the view using the with
method.
return View::make('blog')->with('posts', $posts);
It's probably worth mentioning that as of Laravel 5, passing data to the view is now done like this:
return view("blog", ["posts"=>$posts]);
Or:
return view("blog", compact("posts"));
Documentation is available here.