Last active
September 2, 2019 12:22
-
-
Save shibbirweb/57fa1ce1700ae62d29438896ef9f42e5 to your computer and use it in GitHub Desktop.
Generate auto serial number of Laravel Pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @php | |
| //get the serial number of pagination | |
| public static function paginateSerial($data) | |
| { | |
| return $data->perPage() * ($data->currentPage() - 1); | |
| } | |
| @endphp | |
| @php | |
| $serial = paginateSerial($categories); //get the start integer | |
| @endphp | |
| @foreach($categories as $category) | |
| <tr> | |
| <td title="{{ $serial }}">{{ $serial++ }}</td> | |
| </tr> | |
| @endforeach | |
| <!-- pagination --> | |
| {{ $categories->links() }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment