如何从laravel5.5获取数据?

如何从laravel5.5获取数据?,laravel,Laravel,我使用的是Laravel5.5,我想从我的查看页面(home.blade.php)查看数据库中的数据 @foreach($home as$key=>$data) {{$data->created_at} {{$data->category} {{$data->reportitle} {{$data->reportdetails} {{$data->seenstat} {{$data->actionstat} {{$data->donestat} @endforeach 这必须有效(正如@Na

我使用的是Laravel5.5,我想从我的查看页面(home.blade.php)查看数据库中的数据


@foreach($home as$key=>$data)
{{$data->created_at}
{{$data->category}
{{$data->reportitle}
{{$data->reportdetails}
{{$data->seenstat}
{{$data->actionstat}
{{$data->donestat}
@endforeach
这必须有效(正如@Nazmul所说):

@foreach($fyp作为$data)
{{$data->created_at}
{{$data->category}
{{$data->reportitle}
{{$data->reportdetails}
{{$data->seenstat}
{{$data->actionstat}
{{$data->donestat}
@endforeach
只需遵循代码即可

Route::get('home', function () {

            $home = DB::table('reports')->get();

            return view('home', compact('home'));

});
在您的查看页面中

<table>
                        <tbody>
                    @foreach($home as $key => $data)
                        <tr>
                            <th>{{$data->created_at}}</th>
                            <th>{{$data->category}}</th>
                            <th>{{$data->reportitle}}</th>
                            <th>{{$data->reportdetails}}</th>
                            <th>{{$data->seenstat}}</th>
                            <th>{{$data->actionstat}}</th>
                            <th>{{$data->donestat}}</th>
                        </tr>
                    @endforeach
                        </tbody>
                    </table>

@foreach($home as$key=>$data)
{{$data->created_at}
{{$data->category}
{{$data->reportitle}
{{$data->reportdetails}
{{$data->seenstat}
{{$data->actionstat}
{{$data->donestat}
@endforeach

我希望这将对您有所帮助。

您通过了
$fyp
变量而不是
$home
。循环通过
$fyp
变量
<table>
                        <tbody>
                    @foreach($home as $key => $data)
                        <tr>
                            <th>{{$data->created_at}}</th>
                            <th>{{$data->category}}</th>
                            <th>{{$data->reportitle}}</th>
                            <th>{{$data->reportdetails}}</th>
                            <th>{{$data->seenstat}}</th>
                            <th>{{$data->actionstat}}</th>
                            <th>{{$data->donestat}}</th>
                        </tr>
                    @endforeach
                        </tbody>
                    </table>