我正在尝试用我的数据库中的数据填充表我用 laravel 4.2 完成了但在 4.1 中它不起作用 错误是
Undefined variable: questions (View: C:\wamp\www\happy_Road\app\views\home\home.blade.php)
这是风景
<div class="col-md-12">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Thémathique</th>
<th>Question</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach ($questions as $question)
<tr>
<td>{{ $question->theme }}</td>
<td>{{ $question->question }}</td>
<td >
</td>
</tr>
@endforeach
</tbody>
<tfoot></tfoot>
</table>
{{ $questions->links(); }}
</div>
这是 Controller
public function index()
{
if (Auth::check())
{
$questions = questionList::paginate(10);
return View::make('home.home')->with('user',Auth::user());
}
else
{
return Redirect::to('login')->with('message',"Vous devez vous connecter d'abord");
}
}
这个方法有什么问题!!请帮忙!谢谢 :)
最佳答案
将问题传递给您的 View
return View::make('home.home')
->with('questions', $questions)
->with('user', Auth::user());
关于php - laravel 4.1 用数据库中的数据填充表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25566787/