mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
修正分页类
This commit is contained in:
@@ -44,7 +44,7 @@ abstract class Paginator
|
|||||||
'fragment' => ''
|
'fragment' => ''
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(Collection $items, $listRows, $currentPage = null, $simple = false, $total = null, $options = [])
|
public function __construct($items, $listRows, $currentPage = null, $simple = false, $total = null, $options = [])
|
||||||
{
|
{
|
||||||
$this->options = array_merge($this->options, $options);
|
$this->options = array_merge($this->options, $options);
|
||||||
|
|
||||||
@@ -53,17 +53,18 @@ abstract class Paginator
|
|||||||
$this->simple = $simple;
|
$this->simple = $simple;
|
||||||
$this->listRows = $listRows;
|
$this->listRows = $listRows;
|
||||||
|
|
||||||
|
$this->items = PaginatorCollection::make($items, $this);
|
||||||
|
|
||||||
if ($simple) {
|
if ($simple) {
|
||||||
$this->currentPage = $this->setCurrentPage($currentPage);
|
$this->currentPage = $this->setCurrentPage($currentPage);
|
||||||
$this->hasMore = count($items) > ($this->listRows);
|
$this->hasMore = count($this->items) > ($this->listRows);
|
||||||
$items = $items->slice(0, $this->listRows);
|
$this->items = $this->items->slice(0, $this->listRows);
|
||||||
} else {
|
} else {
|
||||||
$this->lastPage = (int)ceil($total / $listRows);
|
$this->lastPage = (int)ceil($total / $listRows);
|
||||||
$this->currentPage = $this->setCurrentPage($currentPage);
|
$this->currentPage = $this->setCurrentPage($currentPage);
|
||||||
$this->hasMore = $this->currentPage < $this->lastPage;
|
$this->hasMore = $this->currentPage < $this->lastPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->items = PaginatorCollection::make($items, $this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function items()
|
public function items()
|
||||||
@@ -165,6 +166,7 @@ abstract class Paginator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据是否足够分页
|
* 数据是否足够分页
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasPages()
|
public function hasPages()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user