diff --git a/UPGRADE.md b/UPGRADE.md index 39cf26839..bc978cb8e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -31,11 +31,23 @@ Optional things you can delete, if they do not contain anything custom. ### Breaking code changes -**Model->remember() has been removed** -**App::make('paginator')->setCurrentPage(5);** should no longer be used +#### Paginator / setCurrentPage + +**App::make('paginator')->setCurrentPage(5);** should no longer be used, instead pass as the second argument with the `paginate()` method `$model->paginate(25, 5);` + +Old code: + + App::make('paginator')->setCurrentPage($page); + $model->paginate($perPage); + +New code: + + $model->paginate($perPage, $page); ##### Paginator API changes +The following methods have changed: + getTotal() -> total() getCurrentPage() -> currentPage() getLastPage() -> lastPage() diff --git a/modules/backend/behaviors/UserPreferencesModel.php b/modules/backend/behaviors/UserPreferencesModel.php index 196f5d3c3..a28f5468a 100644 --- a/modules/backend/behaviors/UserPreferencesModel.php +++ b/modules/backend/behaviors/UserPreferencesModel.php @@ -1,6 +1,5 @@ getCacheKey(), 1440, function() use ($item) { - return $item->scopeFindRecord( - $this->model, - $this->recordCode, - $item->userContext - )->first(); - }); + $record = $item->scopeFindRecord($this->model, $this->recordCode, $item->userContext) + ->remember(1440, $this->getCacheKey()) + ->first(); return $record ?: null; } diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index f3330392e..1ea0bf1d5 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -70,6 +70,11 @@ class Lists extends WidgetBase */ public $recordsPerPage; + /** + * @var int Current page number. + */ + protected $currentPageNumber; + /** * @var string Message to display when there are no records in the list. */ @@ -230,7 +235,7 @@ class Lists extends WidgetBase */ public function onPaginate() { - App::make('paginator')->setCurrentPage(post('page')); + $this->currentPageNumber = post('page'); return $this->onRefresh(); } @@ -456,7 +461,7 @@ class Lists extends WidgetBase else { $model = $this->prepareModel(); $records = ($this->showPagination) - ? $model->paginate($this->recordsPerPage) + ? $model->paginate($this->recordsPerPage, $this->currentPageNumber) : $model->get(); } @@ -959,7 +964,7 @@ class Lists extends WidgetBase /* * Persist the page number */ - App::make('paginator')->setCurrentPage(post('page')); + $this->currentPageNumber = post('page'); return $this->onRefresh(); }