【发布时间】:2020-02-21 17:33:17
【问题描述】:
我已成功检索数据并将其显示在表格列表中,但我的列表没有分页
我尝试每页显示 15 个数据,但它在页面中一次显示所有数据。我的数据来自 API。
我的控制器
public function index()
{
$response = $this->client->get('getUserIndex')->getBody();
$content = json_decode($response->getContents(),true);
$collection = new \Illuminate\Support\Collection($content);
$total = count($collection['data']);
$paginationRecord = CollectionPaginate::paginate($collection, $total, 15);
return view('configuration.comuserprofiles.ComUserProfilesList', compact('paginationRecord'));
}
我的表格视图的一半
@foreach($paginationRecord as $i=>$user)
@foreach($user as $i => $u)
@php
$currentRecordno = 1;
// dd($u['irel__com_access_level']['ID']);
@endphp
<tr>
<td>{{ $currentRecordno + $i }}</td>
<td>{{ $u['ID'] }}</td>
<td>{{ $u['NICK_NAME'] }}</td>
<td>{{ $u['PWD_INVALID_HIT'] }}</td>
</tr>
@endforeach
我的分页刀片
<div class="row row-pagination">
<div class="col-sm-6 text-left">
<small class="text-muted inline m-t-sm m-b-sm"><font color="#00000f">{{ $paginationRecord->total() }} record/s found </font></small>
</div>
<div class="col-md-6 text-right text-center-xs">
<ul>
{{ $paginationRecord->links() }}
</ul>
</div>
</div>
我希望每页显示 15 条记录
【问题讨论】:
标签: php json laravel pagination