Ifrit's avatar
Level 2

Pagination not working

I'm trying to create a pagination, the problem is, is that when I try to create the pagination I get this error

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.
http://laravel-site.test/livewire/message/category.show?page=2

I'm using laravel and livewire.

This is my code

    <?php

    namespace App\Http\Livewire\Categories;

    use Illuminate\Pagination\Paginator;
    use Livewire\Component;

    class Show extends Component
    {
        public $category;

        public function render()
        {
            $products = $this->category->products->paginate(10);

            return view('livewire.categories.show', ['category' => $this->category, 'products' => $products]);
        }
    }

and this is my blade file

    <table class="min-w-full divide-y divide-gray-200">
        <tbody>
            @foreach($products as $product)
                <tr>
                    <td>
                        {{ $product->name }}
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <div>
        {{ $products->links() }}
    </div>

This is in my Category model

    public function products()
    {
        return $this->hasMany(Product::class);
    }
0 likes
1 reply
Snapey's avatar

You can only use pagination on GET routes

Please or to participate in this conversation.