phppaginationlaravel-4.2

Laravel 4.2 auto incrementing row number with pagination


I have 15 rows in per page. And I want to increment the row count number even on paginate.

***** I Use Laravel 4.2 *****

<div class="portlet-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th class="col-md-1">no</th>
                            <th class="col-md-2">name</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $i = 1;
                        $count = Permit::count();
                        $stat = Config::get('permit.status');
                        $color = Config::get('permit.color');
                        ?>
                        @foreach ($list as $lst)

                            <tr>
                                <td>{{ $i++ }}</td>
                                <td>{{ HTML::linkRoute('dashboard.admin.permit.show',$lst->name, array($lst->id)) }}</td>
                            </tr>
                        @endforeach
                        <?php echo $list->appends(Input::except('page'))->links(); ?>
                        </tbody>
                    </table>
                </div>
            </div>

But when I goes to next page the $count var starts from beginning. How can I get $i = 16 and it will increment and so on?


Solution

  • just get number of page and how much result perpage

    $i = $i+ ((number_of_page-1) * perpage)