Issue
I am trying to retrieve 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}}
</td><td>{{$li->mobile}}</td>
@endforeach
{!! $lists->render() !!}
but I am using paginate in the controller:
$lists=telephone::orderBy('name')->simplePaginate(10);
So, the first page's serial number is ok. But for the second page i
starts from 1 again.
Solution
UPDATE:
The solution below starts from 0 instead of 1 for the first page. To start from 1:
$i = ($lists->perPage() * ($lists->currentPage() - 1)) + 1;
Try setting $i
to $lists->perPage() * ($lists->currentPage() - 1)
$i = $lists->perPage() * ($lists->currentPage() - 1);
Answered By - Doom5
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.