Answer the question
In order to leave comments, you need to log in
How to customize paginator in Laravel?
Hello. I can’t figure out how to make the paginator output me 1 2 3 4 5 ... 11 now it displays me so it turns out I want 6 to not be a
controller
$paginator = News::paginate(10);
return view('news', ['paginator'=>$paginator]);
@if ($paginator->hasPages())
<ul class="pagination">
@if ($paginator->onFirstPage())
<li class="disabled"><span>«</span></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a></li>
@endif
@foreach ($elements as $element)
@if (is_string($element))
<li class="disabled"><span>{{ $element }}</span></li>
@endif
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="active"><span>{{ $page }}</span></li>
@else
<li><a href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
@if ($paginator->hasMorePages())
<li><a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a></li>
@else
<li class="disabled"><span>»</span></li>
@endif
</ul>
@endif
{{ $paginator->onEachSide(1)->links('paginate') }}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question