Simplificadas cosas en Usuarios

This commit is contained in:
2021-05-02 18:20:18 -04:00
parent 0c282c10ef
commit b20d95cb81
4 changed files with 82 additions and 82 deletions

View File

@@ -20,9 +20,10 @@ class PaginatorService extends ServiceProvider {
'to' => "int",
'total' => "int",
'current_page' => "int",
'last_page' => "int"
'last_page' => "int",
'links' => 'array'
])]
public function paginate(int $perPage, int $page, int $total) {
public function paginate(int $perPage, int $page, int $total, string $route, array $data = []) {
// Se mostraran entre 1 o mas elementos por pagina
$perPage = max(1, $perPage);
@@ -42,6 +43,13 @@ class PaginatorService extends ServiceProvider {
'total' => $total,
'current_page' => $currentPage,
'last_page' => $lastPage,
'links' => [
'first' => route($route, array_merge(['page' => 1, 'per_page' => $perPage], $data)),
'prev' => $currentPage - 1 >= 1 ? route($route, array_merge(['page' => $currentPage - 1, 'per_page' => $perPage], $data)) : null,
'current' => route($route, array_merge(['page' => $currentPage, 'per_page' => $perPage], $data)),
'next' => $currentPage + 1 <= $lastPage ? route($route, array_merge(['page' => $currentPage + 1, 'per_page' => $perPage], $data)) : null,
'last' => route($route, array_merge(['page' => $lastPage, 'per_page' => $perPage], $data)),
]
];
}
}