我的控制器有问题,因为我有以下代码:
public function index()
{
$all = Nodes::all();
return Response::json($all);
}
我的问题是,我需要对这个响应进行计数,我不知道如何表达,因为在我看来,我有以下错误。
未定义的变量:all(视图:C:''example2''htdocs''copiaAngus''app''views''nodes''index.blade.php)
PHP
foreach ($all as $user)
{
var_dump($user->id);
}
相反,使用:
return View::make('nodex/index')->with('all', $all);
然后在视图中,您的代码应该可以工作。