我正在使用laravel 5.6并尝试将分页添加到引导数据表。但这不起作用。我遇到了错误。请帮助我找出我所做的错误。
错误
方法照亮\数据库\口才\集合::链接不存在。
designation.blade.php(View)
@if(count($designations)>=1)
<table class="table table-dark" id="designationTable">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Designation Type</th>
<th scope="col">Status</th>
<th scope="col">Create At</th>
<th scope="col">Action</th>
</tr>
</thead>
@foreach ($designations as $designation)
<tbody>
<tr>
<th scope="row">{{$designation->id}}</th>
<td>{{$designation->designation_type}}</td>
<td>{{$designation->status}}</td>
<td>{{$designation->created_at}}</td>
<td>
<button type="" class="btn btn-secondary" id="btn_update_designation">Update</button>
</td>
</tr>
</tbody>
@endforeach
</table>
{{ $designations->links() }}
@endif
您应该在控制器文件中使用paginate()方法。
public function index()
{
$designations = Designation::paginate(10);
return view('xyz',compact('designations'));
}