laravel 5.6数据表分页不起作用

问题描述 投票:1回答:1

我正在使用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
laravel datatable pagination laravel-5.6
1个回答
0
投票

您应该在控制器文件中使用paginate()方法。

public function index()
{
    $designations = Designation::paginate(10);
    return view('xyz',compact('designations'));    
}
© www.soinside.com 2019 - 2024. All rights reserved.