2013-10-16 82 views

回答

1

你应该告知变量名刃:

public function getList() 
{ 
    $posts=\Posts::allPosts(); 
    $this->layout->content=\View::make('admin.posts.list', array('posts' => $posts)); 
} 
1

一个常见的成语使用$ data数组。

public function getList() 
{ 
    $data = array(
     'posts' => Posts::allPosts(), 
     'morestuff' => $variable, 
    ); 

    $this->layout->content=\View::make('admin.posts.list')->with($data); 
} 
0

在这里做最简单的事情可能是使用compact()

public function getList() 
{ 
    $posts = \Posts::allPosts(); 

    $this->layout->content = \View::make('admin.posts.list', compact('posts')); 
} 

它确实基本相同array('posts' => $posts)

相关问题