Database dashboard with auto refresh and pagination
Hi, I have a project with several database tables and want to create a dashboard showing 4 tables with individual pagination. This dashboard should refresh every 10 seconds automatically without any user interaction and should also increase every page number on those tables.
So far I have achieved both pagination and auto refresh with jumping to the next page. The only problem now is, that at the last page, my code counts to infinity and won't jump back to page one. Any ideas on how to solve this problem the best way?
in my livewire blade:
<div wire:poll.10s="goToNextPageAction ">
<table>
</table>
</div>
in my controller:
class Dashboard extends Component
{
use WithPagination;
public function goToNextPageAction()
{
$this->nextPage('table1');
}
public function render()
{
return view('livewire.dashboard', [
'participants' => Participant::paginate(10, ['*'], 'table1')
]);
}
}
thx for help
@newbie360 thanks, that's what I want to achieve. But your way does not work for me. If I just have data for one page, it stays static and just refreshes as wanted. But if I have multiple pages, the counter in the URL increases every evolution by one until infinity without moving to the next page.