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

@@ -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