laravel 4.1使用数据库中的数据填充表

时间:2014-08-29 10:49:45

标签: php mysql json laravel

我正在努力填写来自我的数据库的数据我已经用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>  

这是控制器

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");
        }

}

这种方法有什么问题!!请帮忙! thx :)

1 个答案:

答案 0 :(得分:3)

将问题传递给您的观点

return View::make('home.home')
    ->with('questions', $questions)
    ->with('user', Auth::user());