@if ($paginator->total()>0)

        <?php
            $items_count = 3;
            $show_first_item = false;
            $show_last_item = false;

            $limit_start= 1;
            $limit_end= 1;
            if (count($elements[0]) > $items_count*2) {
                $limit_start= $paginator->currentPage() - 1;
                $limit_end= $limit_start + 2;
            }

            if($paginator->currentPage() >= $items_count) {
                $show_first_item= true;
            }
            if($paginator->lastPage() > $paginator->currentPage() + 1) {
                $show_last_item= true;
            }
        ?>

    <div class="row">
        <div class="col-md-6">

                Showing {{($paginator->currentpage()-1)*$paginator->perpage()+1}}
                to {{($paginator->hasMorePages())?
                ($paginator->currentpage()*$paginator->perpage()):
                $paginator->total()}}
                of  {{$paginator->total()}} entries

        </div>
        <div class="col-md-6">
         <div class="pull-right">
             <nav  aria-label="Page navigation">
                 <ul class="pagination justify-content-end">
                     @if ($paginator->onFirstPage())
                         <li class="page-item disabled">
                             <a class="page-link" href="#" tabindex="-1">< Previous </a>
                         </li>
                     @else
                         <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}">< Previous </a></li>
                     @endif

                         @foreach ($elements as $element)
                             {{-- "Three Dots" Separator --}}
                             @if (is_string($element))
                                 <li class="page-item disabled"><span class="">{{ $element }}</span></li>
                             @endif

                             {{-- Array Of Links --}}
                             @if (is_array($element))

                                 @foreach ($element as $page => $url)

                                     @if(count($element)>5)

                                         @if($show_first_item and $page == 1)
                                             <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
                                             @if($paginator->currentPage()!= 3)
                                                 <li class="page-item disabled"><a class="page-link">...</a></li>
                                             @endif
                                         @endif

                                         @if($page >= $limit_start and $page <= $limit_end)
                                             @if ($page == $paginator->currentPage())
                                                 <li class="page-item active"><a href=""><span class="page-link">{{ $page }}</span></a></li>
                                             @else
                                                 <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
                                             @endif
                                         @endif

                                         @if($show_last_item and $page == $paginator->lastPage())
                                             @if($paginator->currentPage()!= $paginator->lastPage()-2)
                                                 <li class="page-item disabled"><a class="page-link">...</a></li>
                                             @endif
                                             <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
                                         @endif

                                     @else

                                         @if ($page == $paginator->currentPage())
                                                 <li class="page-item active">
                                                     <a class="page-link">{{ $page }}</a>
                                                 </li>
                                             @else
                                                 <li class="page-item">
                                                     <a class="page-link" href="{{ $url }}">{{ $page }}</a>
                                                 </li>
                                             @endif

                                     @endif

                                 @endforeach

                             @endif
                         @endforeach

                     @if ($paginator->hasMorePages())
                         <li class="page-item">
                             <a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next"> Next ></a>
                         </li>
                     @else
                         <li class="page-item disabled">
                             <a class="page-link" href="#"> Next ></a>
                         </li>
                     @endif
                 </ul>
             </nav>
         </div>
        </div>
    </div>
@endif
