我在Laravel 5中实施服务器端分页时遇到了一些问题。 您有任何想法请告诉
答案 0 :(得分:1)
试试这个
//in controller
$users = \App\User::paginate(15)
return view('your desired view file name', compact('users'));
// in view
<div class="text-center text-muted" role="status" aria-live="polite">Showing {{$users->firstItem()}} to {{$users->lastItem()}} of {{$users->total()}} entries</div>
<div style="display:flex;justify-content:center;align-items:center;" >
<p></p>
{!! with(new Illuminate\Pagination\BootstrapThreePresenter($users))->render()!!}
</div>
答案 1 :(得分:0)
在控制器中,您可以像下面那样进行连接
$users = \App\User::paginate(15)
return view('template.file', compact('users'));
并在View文件中添加以下内容
<table>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td> {{ $user->name }} </td>
</tr>
@endforeach
</tbody>
</table>
{!! $users->appends(\Input::except('page'))->render() !!}
最后一行呈现分页链接。