Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add limit to budget #3150
James Cole723696b971fd
diff --git a/app/Api/V1/Controllers/Autocomplete/BudgetController.php b/app/Api/V1/Controllers/Autocomplete/BudgetController.phpindex 1c2634dadf..296c12d6ab 100644--- a/app/Api/V1/Controllers/Autocomplete/BudgetController.php+++ b/app/Api/V1/Controllers/Autocomplete/BudgetController.php@@ -65,7 +65,7 @@ class BudgetController extends Controllerpublic function budgets(AutocompleteRequest $request): JsonResponse{$data = $request->getData();- $result = $this->repository->searchBudget($data['query']);+ $result = $this->repository->searchBudget($data['query'], $data['limit']);$filtered = $result->map(static function (Budget $item) {return [diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex da41d696e0..14dd528e30 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -238,10 +238,11 @@ class BudgetRepository implements BudgetRepositoryInterface/*** @param string $query+ * @param int $limit** @return Collection*/- public function searchBudget(string $query): Collection+ public function searchBudget(string $query, int $limit): Collection{$search = $this->user->budgets();@@ -251,7 +252,7 @@ class BudgetRepository implements BudgetRepositoryInterface$search->orderBy('order', 'ASC')->orderBy('name', 'ASC')->where('active', 1);- return $search->get();+ return $search->take($limit)->get();}/**diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.phpindex 9da1aa922b..bf58a3f739 100644--- a/app/Repositories/Budget/BudgetRepositoryInterface.php+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php@@ -138,10 +138,10 @@ interface BudgetRepositoryInterface/*** @param string $query- *+ * @param int $limit* @return Collection*/- public function searchBudget(string $query): Collection;+ public function searchBudget(string $query, int $limit): Collection;/*** @param Budget $budgetdiff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.phpindex f4b9f0049d..eccbe83b57 100644--- a/app/Support/Search/Search.php+++ b/app/Support/Search/Search.php@@ -248,7 +248,7 @@ class Search implements SearchInterfacebreak;break;case 'budget':- $result = $this->budgetRepository->searchBudget($modifier['value']);+ $result = $this->budgetRepository->searchBudget($modifier['value'], 25);if ($result->count() > 0) {$collector->setBudgets($result);}