mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Take page size into account. [skip ci]
This commit is contained in:
parent
13e59105ec
commit
23c0bb49c4
@ -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:
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user