I'm trying to create a pagination, the problem is, is that when I trying to create the pagination I get this error
Method IlluminateDatabaseEloquentCollection::pagination does not exist.
I'm using laravel and livewire.
This is my code
$products = $this->category->products->pagination(10);
This is in my Category model
public function products()
{
return $this->hasMany(Product::class);
}
UPDATE
This is my whole code for my livewire
<?php
namespace AppHttpLivewireCategories;
use IlluminatePaginationPaginator;
use LivewireComponent;
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 my livewire.categories.show 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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…