bootstrap-4.blade.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. @if ($paginator->hasPages())
  2. @php
  3. $totalPage = $paginator->lastPage();
  4. $pageGroup = ceil($paginator->currentPage() / 5);
  5. $last = $pageGroup * 5;
  6. $first = $last - 4;
  7. $last = ($overFlow = $last > $totalPage) ? $totalPage : $last;
  8. @endphp
  9. {{-- {{ dd( $first) }}--}}
  10. {{-- dd( $totalPage);--}}
  11. {{-- {{ dd(($pageGroup - 1) * 5) }}--}}
  12. {{-- {{ dd($paginator->currentPage()) }}--}}
  13. {{-- {{ dd((($pageGroup + 1) * 5) - 4) }}--}}
  14. <ul class="custom-pagination">
  15. {{-- Previous Page Link --}}
  16. @if ($paginator->currentPage() <= 5)
  17. <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.first')">
  18. <span class="page-link" aria-hidden="true">&laquo;</span>
  19. </li>
  20. <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
  21. <span class="page-link" aria-hidden="true">&lsaquo;</span>
  22. </li>
  23. @else
  24. <li class="page-item">
  25. <a class="page-link" href="{{ $paginator->url(1) }}" rel="prev" aria-label="@lang('pagination.first')">&laquo;</a>
  26. </li>
  27. <li class="page-item">
  28. <a class="page-link" href="{{ $paginator->url(($pageGroup - 1) * 5) }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
  29. </li>
  30. @endif
  31. {{-- Pagination Elements --}}
  32. @for ($page = $first; $page <= $last; $page++)
  33. @if ($page >= 1 && $page <= $paginator->lastPage())
  34. @if ($page == $paginator->currentPage())
  35. <li class="page-item active"><span class="page-link">{{ $page }}</span></li>
  36. @else
  37. <li class="page-item"><a class="page-link" href="{{ $paginator->url($page) }}">{{ $page }}</a></li>
  38. @endif
  39. @endif
  40. @endfor
  41. {{-- {{ dd(ceil($totalPage / $paginator->perPage()) * $paginator->perPage() - $paginator->currentPage() >= 5) }}--}}
  42. {{-- Next Page Link --}}
  43. @if (! $overFlow && ! ($first + 5 > $totalPage))
  44. <li class="page-item">
  45. <a class="page-link" href="{{ $paginator->url( $first + 5 ) }}" rel="next" aria-label="@lang('pagination.next')">&rsaquo;</a>
  46. </li>
  47. <li class="page-item">
  48. <a class="page-link" href="{{ $paginator->url($paginator->lastPage()) }}" rel="last" aria-label="@lang('pagination.last')">&raquo;</a>
  49. </li>
  50. @else
  51. <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
  52. <span class="page-link" aria-hidden="true">&rsaquo;</span>
  53. </li>
  54. <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.last')">
  55. <span class="page-link" aria-hidden="true">&raquo;</span>
  56. </li>
  57. @endif
  58. </ul>
  59. @endif