micky micky - 9 months ago 52
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.


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

$i = $lists->perPage() * ($lists->currentPage()-1);