修正分页类

This commit is contained in:
yunwuxin
2016-05-09 12:31:53 +08:00
parent 4633f240d0
commit 67fd89cace

View File

@@ -44,7 +44,7 @@ abstract class Paginator
'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);
@@ -53,17 +53,18 @@ abstract class Paginator
$this->simple = $simple;
$this->listRows = $listRows;
$this->items = PaginatorCollection::make($items, $this);
if ($simple) {
$this->currentPage = $this->setCurrentPage($currentPage);
$this->hasMore = count($items) > ($this->listRows);
$items = $items->slice(0, $this->listRows);
$this->hasMore = count($this->items) > ($this->listRows);
$this->items = $this->items->slice(0, $this->listRows);
} else {
$this->lastPage = (int)ceil($total / $listRows);
$this->currentPage = $this->setCurrentPage($currentPage);
$this->hasMore = $this->currentPage < $this->lastPage;
}
$this->items = PaginatorCollection::make($items, $this);
}
public function items()
@@ -165,6 +166,7 @@ abstract class Paginator
/**
* 数据是否足够分页
* @return boolean
*/
public function hasPages()
{