
@php
  if($pagination->lastPage() <= 10){
      $awal = 1;
      $akhir = $pagination->lastPage();
      $shortAwal = false;
      $shortAkhir = false;

  }
  else{
      if(($pagination->currentPage()+5) >= $pagination->lastPage()){
          $awal = $pagination->lastPage()-7;
          $akhir = $pagination->lastPage();
          $shortAwal = true;
          $shortAkhir = false;
      }elseif($pagination->currentPage() > 7){
          $awal = $pagination->currentPage()-4;
          $akhir = $pagination->currentPage()+4;
          $shortAwal = true;
          $shortAkhir = true;
      }else{
          $awal = 1;
          $akhir = 10;
          $shortAwal = false;
          $shortAkhir = true;
      }
  }
@endphp
<div class="row">
    <div class="col-sm-6">
        <ul class="pagination pagination-alt-primary">
            <li class="page-item"><a @if($pagination->currentPage() != 1) href="{{ $pagination->url(1) }}" @endif class="page-link"><i data-feather="chevrons-left"></i></i></a></li>
            <li class="page-item"><a @if($pagination->currentPage() != 1) href="{{ $pagination->url(($pagination->currentPage()-1)) }}" @endif class="page-link"><i data-feather="chevron-left"></i></a></li>

            @if($shortAwal == true)
              <li class="page-item"><a class="page-link">...</a></li>
            @endif
            @for($i=$awal; $i <= $akhir; $i++)
                <li class="page-item @if($pagination->currentPage()==$i) active @endif"><a href="{{ $pagination->url($i) }}" class="page-link">{{ $i }}</a></li>
            @endfor
            @if($shortAkhir == true)
                <li class="page-item"><a class="page-link">...</a></li>
            @endif

            <li class="page-item"><a @if($pagination->currentPage() != $pagination->lastPage()) href="{{ $pagination->url(($pagination->currentPage()+1)) }}" @endif class="page-link"><i data-feather="chevron-right"></i></a></li>
            <li class="page-item"><a @if($pagination->currentPage() != $pagination->lastPage()) href="{{ $pagination->url($pagination->lastPage()) }}" @endif class="page-link"><i data-feather="chevrons-right"></i></a></li>
        </ul>
    </div>
    <div class="col-sm-6 text-right">
        <p style="margin-bottom: 0;margin-top: 10px;">Page {{ $pagination->currentPage() }} of {{ $pagination->lastPage() }} from {{ $pagination->total() }} entries</p>
    </div>
</div>
