Lina's avatar
Level 1

Laravel how to modify pagination on vendor correctly

Hello

what I want to do is to modify the pagination page by default of laravel to change the layout (CSS) and some html things, he identified the file path a modification that is:

provider / laravel / framework / src / Light / Page / resources / views / default.blade.php

And I want to change it to a file that called it new.blade.php with a paginator conntent changeing some class and styles.

What is the right way to change the vendor file having in count that when I do a "composer install" or "composer update" the file used to do the pagination should be the new.blade.php

0 likes
1 reply
Lina's avatar
Lina
OP
Best Answer
Level 1

SOLVED:

@if($posts->total() > 10)
    <div class="card text-center hoverable">
        {{ $posts->render('pagination.default') }} <!--- This is a custom view on resources/views/pagination/default.blade.php
    </div>
@endif 

Content:

@if ($paginator->hasPages())
    <ul class="pagination">

        @if ($paginator->onFirstPage())
            <li class="disabled">
                <a>
                    <i class="material-icons">chevron_left</i>
                </a>
            </li>
        @else
            <li>
                <a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="waves-effect">
                    <i class="material-icons">chevron_left</i>
                </a>
            </li>
        @endif

        @foreach ($elements as $element)
            @if (is_string($element))
                <li class="disabled">
                    <a href="javascript:void(0);" class="waves-effect">
                        {{ $element }}
                    </a>
                </li>
            @endif

            @if (is_array($element))
                @foreach ($element as $page => $url)
                    @if ($page == $paginator->currentPage())
                        <li class="active">
                            <a href="javascript:void(0);" class="waves-effect">
                                {{ $page }}
                            </a>
                        </li>
                    @else
                        <li>
                            <a href="{{ $url }}" class="waves-effect">
                                {{ $page }}
                            </a>
                        </li>
                    @endif
                @endforeach
            @endif
        @endforeach

        @if ($paginator->hasMorePages())
            <li>
                <a href="{{ $paginator->nextPageUrl() }}" rel="next" class="waves-effect">
                    <i class="material-icons">chevron_right</i>
                </a>
            </li>
        @else
            <li class="disabled">
                <a>
                    <i class="material-icons">chevron_right</i>
                </a>
            </li>
        @endif
    </ul>
@endif

Please or to participate in this conversation.