as I can page 2 lists with their page each one that at the time of paging does not change the data in the 2 lists if only change where I am paging.
as I can page 2 lists with their page each one that at the time of paging does not change the data in the 2 lists if only change where I am paging.
When you create your query with Eloquent you simply add a different word that will be the pager parameter for each list, this is known as $pageName
:
$queryLista1->paginate(10, ['*'], 'pagina');
$queryLista2->paginate(5, ['*'], 'paginalista2');
If you want more information about the method, look in Illuminate \ Database \ Eloquent \ Builder.php
/**
* Paginate the given query.
*
* @param int $perPage
* @param array $columns
* @param string $pageName
* @param int|null $page
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*
* @throws \InvalidArgumentException
*/
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$query = $this->toBase();
$total = $query->getCountForPagination();
$this->forPage(
$page = $page ?: Paginator::resolveCurrentPage($pageName),
$perPage = $perPage ?: $this->model->getPerPage()
);
return new LengthAwarePaginator($this->get($columns), $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => $pageName,
]);
}