Laravel 5 Tutorial : Create a custom Laravel5.3 Pagination with Bootstrap Templates

Laravel 5.3 Tutorial - How to Create a custom Laravel 5.3 Pagination with Bootstrap Templates step by step for beginners? this lessons will show you how to create pagination in laravel 5.3 and customizing it with bootstrap templates.

At the previews lessons we have create simple Pagination with Eloquent & Query Builder in Laravel 5.3, so please read it before.

Video Tutorial Customizing Bootstrap Pagination Templates

Watch this video tutorial and download all source code above.


Full source code Pagination with bootstrap in Laravel 5.3

Pagination.blade.php (resources\views\admin\posts\pagination.blade.php)

@if ($paginator->hasPages())
  <ul class="pager">
    <!-- Previous Link Page -->
    @if ($paginator->onFirstPage())
      <li class="disabled">
        <span class="glyphicon glyphicon-menu-left" aria-hidden="true"> Previews</span>
      </li>
    @else
      <li>
        <a href="{{ $paginator->previousPageUrl() }}" rel="prev">
        <span class="glyphicon glyphicon-menu-left" aria-hidden="true"> Previews</span></a>
      </li>
    @endif

    <!-- Pagination Elements -->
    @foreach ($elements as $element)
      @if (is_string($element))
        <li class="disabled">
          <span>{{ $element }}</span>
        </li>
      @endif
      <!-- Array Of Links -->
      @if(is_array($element))
        @foreach($element as $page => $url)
          @if ($page == $paginator->currentPage())
            <li clas="active my-active">
              <span>{{ $page }}</span>
            </li>
          @else
            <li>
              <a href="{{ $url }}">{{ $page }}</a>
            </li>
          @endif
        @endforeach
      @endif
    @endforeach
    <!-- Next Link Page -->
    @if($paginator->hasMorePages())
      <li>
        <a href="{{ $paginator->nextPageUrl() }}" rel="next">
        Next <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></a>
      </li>
    @else
      <li class="disabled">
        Next <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
      </li>
    @endif
  </ul>
@endif

Next, we need to edit our post page (resources\views\admin\posts\allposts.blade.php)

Allposts.blade.php

{!! $posts->links('admin/posts/pagination') !!}

More laravel tutorial



See you next lessons ...

Recomended Tutorials

Facebook
Blogger

0 Response to "Laravel 5 Tutorial : Create a custom Laravel5.3 Pagination with Bootstrap Templates"

Post a Comment