What seems to be the problem:
I have done everything as in the documentations but pagination don’t work at all even wire:click
seems has no action
Steps to Reproduce:
Form web.php
Route::get( 'show-by-categories/{name}', [ ProductCategory::class, 'render' ] )->name( 'show.by.categories' );
Livewire\Component
use Livewire\WithPagination;
class ProductCategory extends Component {
use WithPagination;
public function render( $name ) {
$mainCategory = Category::whereTranslation( 'name', $name )->first();
$subCategory = ProductSubCategory::whereProductCategoryId( $mainCategory->id );
return view( 'livewire.customer-product.category.product-category', [
'subCategories' => $subCategory->paginate( 1 ),
'mainCategory' => $mainCategory
] );
}
}
Here is the product_category.blade
@foreach($subCategories as $subCategory)
<div class="col-xl-2 col-lg-3 col-md-4 col-6 col-grid-box">
<div class="product">
<div class="product-box">
<div class="product-imgbox">
<div class="product-front">
<a href="#">
{!! Html::image('images/productSubCategories/'.$subCategory->image, $subCategory->name, ['class'=>'img-fluid']) !!}
<div
class="categoryLabels">{{ $subCategory->name }}</div>
</a>
</div>
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
{{ $subCategories->links('vendor.pagination.customTemplatePagination') }}
and here is my custom pagination
<div class="col-xl-6 col-md-6 col-sm-12">
@if ($paginator->lastPage() > 1)
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item {{ ($paginator->currentPage() == 1) ? ' disabled' : '' }}">
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" wire:click="previousPage">
<span aria-hidden="true"><i class="fas fa-chevron-left" aria-hidden="true"></i>
</span>
<span class="sr-only">Previous</span>
</a>
</li>
@for ($i = 1; $i <= $paginator->lastPage(); $i++)
<li class="page-item {{ ($paginator->currentPage() == $i) ? ' active' : '' }}">
<a class="page-link" href="{{ $paginator->url($i) }}">{{ $i }}</a>
</li>
@endfor
<li class="page-item {{ ($paginator->currentPage() == $paginator->lastPage()) ? ' disabled' : '' }}">
<button class="page-link" wire:click="nextPage">Next</button>
</li>
</ul>
</nav>
@endif
</div>
Are you using the latest version of Livewire:
Yes using latest version of Livewire 2
Do you have any screenshots or code examples: No