TransWikia.com

Laravel + Livewire: How to fix Pagination Elements Get method error

Stack Overflow Asked by No One on January 4, 2021

Noob here. Help please.

When I search for something in the input box, then clear the input box again. Then I click any of the Pagination Elements: 1, 2, 3, 4, 5, I get this error.

The GET method is not supported for this route. Supported methods: POST.

Here’s the livewire component

search.blade.php

@if ($paginator->hasPages())
    <nav>
        <ul class="pagination">
             {{--Previous Page Link--}}
            @if ($paginator->onFirstPage())
                <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
                <li class="page-item disabled" aria-disabled="true">
                    <span class="page-link" aria-hidden="true">&lsaquo;</span>
                </li>
            @else
                <li class="page-item">
                    <button class="page-link" wire:click="previousPage" rel="prev">&lsaquo;</button>
                </li>
            @endif

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

                 {{--Array Of Links--}}
                @if (is_array($element))
                    @foreach ($element as $page => $url)
                        @if ($page == $paginator->currentPage())
                            <li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li>
                        @else
                            <li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
                        @endif
                    @endforeach
                @endif
            @endforeach

             {{--Next Page Link--}}
            @if ($paginator->hasMorePages())
                <li class="page-item">
                    <button class="page-link" wire:click="nextPage" rel="next" aria-label="@lang('pagination.next')">&rsaquo;</button>
                </li>
            @else
                <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
                <li class="page-item disabled" aria-disabled="true">
                    <span class="page-link" aria-hidden="true">&rsaquo;</span>
                </li>
            @endif
        </ul>
    </nav>
@endif

search-students.blade.php

{{-- CARD BODY --}}
<div class="card-body">
    <div id="example1_wrapper" class="dataTables_wrapper dt-bootstrap4">
        <div class="row">
            <div class="col-sm-12 col-md-6">
                <div id="example1_filter" class="dataTables_filter">
                    <label>Search:<input type="search" class="form-control form-control-sm" placeholder="" wire:model="searchText">
                    </label>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <table id="example1" class="table table-bordered table-striped dataTable dtr-inline" role="grid"
                       aria-describedby="example1_info">
                    <thead>
                    <tr role="row">
                        <th class="sorting_asc" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-sort="ascending">First Name</th>
                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1">Last Name</th>
                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1">Image</th>
                    </thead>
                    <tbody>
                    @foreach($students as $student)

                        <tr role="row" class="odd">
                            <td class="sorting_1 dtr-control">{{ $student->FirstName }}</td>
                            <td>{{ $student->LastName }}</td>
                            <td><img src="StudentImage/{{ $student->ImageLink }}.jpg" width="120" height="150"></td>

                        </tr>
                    @endforeach
                    </tbody>

                    <tfoot>
                    <tr>
                    </tfoot>
                </table>
            </div>
        </div>

        <div class="col-sm-12 col-md-7">
            {{ $students->links('livewire.livewire-pagination') }}
        </div>
    </div>
</div>
</div>
{{-- card body --}}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP