From 163b0a21053c493f35037b108316f0cbf991988e Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 26 Jan 2019 12:09:32 +0100 Subject: [PATCH] Add limit parameter to /budgets/x/transactions API endpoint. --- app/Api/V1/Controllers/BudgetController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Api/V1/Controllers/BudgetController.php b/app/Api/V1/Controllers/BudgetController.php index 6b21f09bfc..4f14df5af7 100644 --- a/app/Api/V1/Controllers/BudgetController.php +++ b/app/Api/V1/Controllers/BudgetController.php @@ -247,7 +247,14 @@ class BudgetController extends Controller public function transactions(Request $request, Budget $budget): JsonResponse { $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; - $type = $request->get('type') ?? 'default'; + + // user can overrule page size with limit parameter. + $limit = $this->parameters->get('limit'); + if (null !== $limit && $limit > 0) { + $pageSize = $limit; + } + + $type = $request->get('type') ?? 'default'; $this->parameters->set('type', $type); $types = $this->mapTransactionTypes($this->parameters->get('type'));