【发布时间】:2019-09-22 15:40:24
【问题描述】:
使用 laravel 5.7 需要在主页 home.blade.php 中显示学生表数据
<table class="table">
<thered>
<tr>
<td>Id</td>
<td>Name</td>
<td>Address</td>
<td>Telephone</td>
<td>Actions</td>
</tr>
</thead>
<tbody>
@foreach ($students as $student)
<tr>
<td>{{$student->id}}</td>
<td>{{$student->name}}</td>
<td>{{$student->address}}</td>
<td>{{$student->telephone}}</td>
<td><a class="button is-outlined" href="">Edit</a></td>
<td><a class="button is-outlined" href="">Delete</a></td>
</tr>
@endforeach
</tbody>
</table>
StudentController.php
public function index()
{
$students = Student::all();
return view('home');
}
web.php
Route::get('StudentController@index');
但收到这样的错误消息,
未定义变量:students(查看:D:\exam\curd\resources\views\home.blade.php)
我该如何解决这个问题?
【问题讨论】: