mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-20 11:33:59 +00:00
Take page size into account. [skip ci]
This commit is contained in:
@@ -155,11 +155,12 @@ class CategoryController extends Controller
|
|||||||
public function show(SCRI $repository, Category $category)
|
public function show(SCRI $repository, Category $category)
|
||||||
{
|
{
|
||||||
$hideCategory = true; // used in list.
|
$hideCategory = true; // used in list.
|
||||||
|
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
$page = intval(Input::get('page'));
|
$page = intval(Input::get('page'));
|
||||||
$set = $repository->getJournals($category, $page);
|
$set = $repository->getJournals($category, $page, $pageSize);
|
||||||
$count = $repository->countJournals($category);
|
$count = $repository->countJournals($category);
|
||||||
$subTitle = $category->name;
|
$subTitle = $category->name;
|
||||||
$journals = new LengthAwarePaginator($set, $count, 50, $page);
|
$journals = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
||||||
$journals->setPath('categories/show/' . $category->id);
|
$journals->setPath('categories/show/' . $category->id);
|
||||||
|
|
||||||
// list of ranges for list of periods:
|
// list of ranges for list of periods:
|
||||||
|
@@ -138,14 +138,15 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
|||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param int $page
|
* @param int $page
|
||||||
|
* @param int $pageSize
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @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.date', 'DESC')
|
||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.id', 'DESC')
|
||||||
|
@@ -74,10 +74,11 @@ interface SingleCategoryRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param int $page
|
* @param int $page
|
||||||
|
* @param int $pageSize
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getJournals(Category $category, $page): Collection;
|
public function getJournals(Category $category, int $page, int $pageSize = 50): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
|
Reference in New Issue
Block a user