Level 122
You can only use pagination on GET routes
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);
}
Please or to participate in this conversation.