I am using the paginator of Laravel to display 100 results per page. In the front of each row I'm currently displaying the ID of the database field. However, I want to display the count.
I've found some threads on stackoverflow solving this issue for Laravel 4
Where they say, you should solve it like this
<?php $count = $players->getFrom(); ?>
@foreach ($players as $player)
<tr>
<td>{{ $count++ }}. </td>
</tr>
@endforeach
or like this
<?php $count = $players->getFrom() + 1; ?>
@foreach ($players as $player)
...
The problem here, is that Laravel 5.1 doesn't have the getForm
method anymore. The upgrade guide says to replace getFrom
by firstItem
, which I did. Unfortunetely, I'm not getting the correct numbers.
I tried it like this
<?php $count = $pages->firstItem() + 1 ?>
@foreach ($pages as $page)
@include('pages.singlepagebasic')
@endforeach
and like this
{{ $count = $pages->firstItem() }}
@foreach ($pages as $page)
@include('pages.singlepagebasic')
@endforeach
//pages.singlebasic.blade.php
{{ $count ++ }}
but my site always displays only the number "2" instead of counting up. How do I achieve that?