mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-23 01:16:46 -06:00
Add limit to budget #3150
This commit is contained in:
parent
858158d886
commit
723696b971
@ -65,7 +65,7 @@ class BudgetController extends Controller
|
||||
public 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 [
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 $budget
|
||||
|
@ -248,7 +248,7 @@ class Search implements SearchInterface
|
||||
break;
|
||||
break;
|
||||
case 'budget':
|
||||
$result = $this->budgetRepository->searchBudget($modifier['value']);
|
||||
$result = $this->budgetRepository->searchBudget($modifier['value'], 25);
|
||||
if ($result->count() > 0) {
|
||||
$collector->setBudgets($result);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user