Take page size into account. [skip ci]

This commit is contained in:
James Cole 2016-04-21 09:04:19 +02:00
parent 13e59105ec
commit 23c0bb49c4
3 changed files with 9 additions and 6 deletions

View File

@ -155,11 +155,12 @@ class CategoryController extends Controller
public function show(SCRI $repository, Category $category)
{
$hideCategory = true; // used in list.
$pageSize = Preferences::get('transactionPageSize', 50)->data;
$page = intval(Input::get('page'));
$set = $repository->getJournals($category, $page);
$set = $repository->getJournals($category, $page, $pageSize);
$count = $repository->countJournals($category);
$subTitle = $category->name;
$journals = new LengthAwarePaginator($set, $count, 50, $page);
$journals = new LengthAwarePaginator($set, $count, $pageSize, $page);
$journals->setPath('categories/show/' . $category->id);
// list of ranges for list of periods:

View File

@ -138,14 +138,15 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
/**
* @param Category $category
* @param int $page
* @param int $pageSize
*
* @return Collection
*/
public function getJournals(Category $category, $page): Collection
public function getJournals(Category $category, int $page, int $pageSize = 50): Collection
{
$offset = $page > 0 ? $page * 50 : 0;
$offset = $page > 0 ? $page * $pageSize : 0;
return $category->transactionjournals()->expanded()->take(50)->offset($offset)
return $category->transactionjournals()->expanded()->take($pageSize)->offset($offset)
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC')

View File

@ -74,10 +74,11 @@ interface SingleCategoryRepositoryInterface
/**
* @param Category $category
* @param int $page
* @param int $pageSize
*
* @return Collection
*/
public function getJournals(Category $category, $page): Collection;
public function getJournals(Category $category, int $page, int $pageSize = 50): Collection;
/**
* @param Category $category