pagination fix
This commit is contained in:
@ -3,6 +3,9 @@
|
||||
namespace Itguild\Tables;
|
||||
|
||||
|
||||
use Exception;
|
||||
use http\Message;
|
||||
|
||||
class Pagination
|
||||
{
|
||||
|
||||
@ -14,13 +17,21 @@ class Pagination
|
||||
|
||||
private string $baseUrl;
|
||||
|
||||
public function __construct($countItem, $perPage, $currentPage, $baseUrl)
|
||||
// public function __construct(int $countItem, array $params, string $baseUrl)
|
||||
// public function __construct($countItem, $perPage, $currentPage, $baseUrl)
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(array $options,)
|
||||
{
|
||||
$this->countItem = $countItem;
|
||||
$this->perPage = $perPage;
|
||||
$this->currentPage = $currentPage;
|
||||
$this->baseUrl = $baseUrl;
|
||||
if (!$options['countItem']) {
|
||||
throw new Exception(message: "countItem is not valid");
|
||||
}
|
||||
$this->countItem = $options['countItem'];
|
||||
$this->perPage = $options['perPage'] ?? 10;
|
||||
$this->currentPage = $options['currentPage'] ?? 1;
|
||||
$this->baseUrl = $options['baseUrl'];
|
||||
$this->baseUrl .= $options['prefix'] ?? '/page';
|
||||
|
||||
$this->countPages = ceil($this->countItem / $this->perPage);
|
||||
}
|
||||
|
Reference in New Issue
Block a user