Reputation: 1
public function getList()
{
$posts=\Posts::allPosts();
$this->layout->content=\View::make('admin.posts.list', $posts);
}
So I'm sending the $posts
array to my view, but I get an error when I try to var_dump(...)
it that it doesn't exist.
Upvotes: 0
Views: 229
Reputation: 226
The easiest thing to do here could be to use compact()
public function getList()
{
$posts = \Posts::allPosts();
$this->layout->content = \View::make('admin.posts.list', compact('posts'));
}
It does basically the same as array('posts' => $posts)
Upvotes: 0
Reputation: 31225
A common idiom to use an $data array.
public function getList()
{
$data = array(
'posts' => Posts::allPosts(),
'morestuff' => $variable,
);
$this->layout->content=\View::make('admin.posts.list')->with($data);
}
Upvotes: 1
Reputation: 87749
You should inform the variable name to Blade:
public function getList()
{
$posts=\Posts::allPosts();
$this->layout->content=\View::make('admin.posts.list', array('posts' => $posts));
}
Upvotes: 1