mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-27 08:46:40 -06:00
Add limit to object groups #3150
This commit is contained in:
parent
bb841e66c7
commit
f777abdeb1
@ -57,7 +57,6 @@ class ObjectGroupController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO add limit
|
||||
* @param AutocompleteRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
@ -66,7 +65,7 @@ class ObjectGroupController extends Controller
|
||||
{
|
||||
$data = $request->getData();
|
||||
$return = [];
|
||||
$result = $this->repository->search($data['query']);
|
||||
$result = $this->repository->search($data['query'], $data['limit']);
|
||||
|
||||
/** @var ObjectGroup $account */
|
||||
foreach ($result as $objectGroup) {
|
||||
|
@ -61,10 +61,11 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function search(string $query): Collection
|
||||
public function search(string $query, int $limit): Collection
|
||||
{
|
||||
$dbQuery = $this->user->objectGroups()->orderBy('order', 'ASC')->orderBy('title', 'ASC');
|
||||
if ('' !== $query) {
|
||||
@ -77,7 +78,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
|
||||
}
|
||||
|
||||
return $dbQuery->get(['object_groups.*']);
|
||||
return $dbQuery->take($limit)->get(['object_groups.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,10 +39,11 @@ interface ObjectGroupRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function search(string $query): Collection;
|
||||
public function search(string $query, int $limit): Collection;
|
||||
|
||||
/**
|
||||
* Delete empty ones.
|
||||
|
Loading…
Reference in New Issue
Block a user