<?php
namespace App\Livewire;
use App\Models\User;
use Livewire\Component;
class Prueba extends Component
{
public $perPage = 10;
public function render()
{
$data = User::paginate($this->perPage);
return view('livewire.prueba', ['data' => $data,]);
}
}
I m trying to implement a pagination with a perPage to control the number of results the user can see per page but I m not getting it to work.
<?php
namespace App\Livewire;
use App\Models\User;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Pagination\Paginator;
class Prueba extends Component
{
use WithPagination;
public $perPage = 10;
public function update()
{
$currentPage = 1;
Paginator::currentPageResolver(function () use ($currentPage) {
return $currentPage;
});
}
public function render()
{
$data = User::paginate($this->perPage);
return view('livewire.prueba', ['data' => $data,]);
}
}
i found this solution I don’t know if is the best one but it works