micky micky - 2 years ago 93
PHP Question

Using serial number iwith paginate

I am trying to retreive serial number in the blade template with variable i.

<?php $i=0;?>
@foreach ($lists as $li)
<tr><td><?php $i++;?>{{$i}}</td><td>{{$li->Name}}</td><td>{{$li->Telephone}}
{!! $lists->render() !!}

but i am using paginate in controller:


so, until the first page the serial number is ok. but for the second page. i starts from 1 again.

Answer Source

Try setting $i to $lists->perPage() * ($lists->currentPage()-1)

$i = $lists->perPage() * ($lists->currentPage()-1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download