Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Commit

Permalink
Сделал возможность оверрайда метода подсчета страниц
Browse files Browse the repository at this point in the history
  • Loading branch information
antshater committed Mar 31, 2016
1 parent 8072664 commit 1d62dce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/GridDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class GridDataProvider
private $csv_url;
private $date_format;
private $dates;
private $count;

/**
* @var string Название грида
Expand Down Expand Up @@ -62,6 +63,23 @@ protected function pagination()
return new GridPagination();
}

/**
* Получение кол-ва страниц
* @return integer
*/
final public function getCount()
{
if (is_null($this->count)) {
$this->count = $this->count();
}
return $this->count;
}

protected function count()
{
return $this->getQuery()->count();
}


/**
* Получение класса пагинации
Expand Down
2 changes: 1 addition & 1 deletion src/GridTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getData($template = null)

$this->buildQuery($searches);

$total = $this->data_provider->getQuery()->count();
$total = $this->data_provider->getCount();
$data = $this->makeQuery($sorting, $limit, $page);

if ($template) {
Expand Down

0 comments on commit 1d62dce

Please sign in to comment.