Skip to content

Instantly share code, notes, and snippets.

@shibbirweb
Last active September 2, 2019 12:22
Show Gist options
  • Select an option

  • Save shibbirweb/57fa1ce1700ae62d29438896ef9f42e5 to your computer and use it in GitHub Desktop.

Select an option

Save shibbirweb/57fa1ce1700ae62d29438896ef9f42e5 to your computer and use it in GitHub Desktop.
Generate auto serial number of Laravel Pagination
@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