Add limit parameter to /budgets/x/transactions API endpoint.

This commit is contained in:
James Cole 2019-01-26 12:09:32 +01:00
parent d33c89a8ee
commit 163b0a2105

View File

@ -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'));