mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add limit to bills. #3150
This commit is contained in:
parent
62fd701808
commit
858158d886
@ -65,7 +65,7 @@ class BillController extends Controller
|
||||
public function bills(AutocompleteRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$result = $this->repository->searchBill($data['query']);
|
||||
$result = $this->repository->searchBill($data['query'], $data['limit']);
|
||||
$filtered = $result->map(
|
||||
static function (Bill $item) {
|
||||
return [
|
||||
|
@ -661,14 +661,15 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchBill(string $query): Collection
|
||||
public function searchBill(string $query, int $limit): Collection
|
||||
{
|
||||
$query = sprintf('%%%s%%', $query);
|
||||
|
||||
return $this->user->bills()->where('name', 'LIKE', $query)->get();
|
||||
return $this->user->bills()->where('name', 'LIKE', $query)->take($limit)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,10 +287,11 @@ interface BillRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchBill(string $query): Collection;
|
||||
public function searchBill(string $query, int $limit): Collection;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
|
@ -235,7 +235,7 @@ class Search implements SearchInterface
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
$result = $this->billRepository->searchBill($modifier['value']);
|
||||
$result = $this->billRepository->searchBill($modifier['value'], 25);
|
||||
if ($result->count() > 0) {
|
||||
$collector->setBills($result);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user