mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 04:34:00 +00:00
Add limit to bills. #3150
This commit is contained in:
@@ -65,7 +65,7 @@ class BillController extends Controller
|
|||||||
public function bills(AutocompleteRequest $request): JsonResponse
|
public function bills(AutocompleteRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $request->getData();
|
$data = $request->getData();
|
||||||
$result = $this->repository->searchBill($data['query']);
|
$result = $this->repository->searchBill($data['query'], $data['limit']);
|
||||||
$filtered = $result->map(
|
$filtered = $result->map(
|
||||||
static function (Bill $item) {
|
static function (Bill $item) {
|
||||||
return [
|
return [
|
||||||
|
@@ -661,14 +661,15 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $query
|
* @param string $query
|
||||||
|
* @param int $limit
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function searchBill(string $query): Collection
|
public function searchBill(string $query, int $limit): Collection
|
||||||
{
|
{
|
||||||
$query = sprintf('%%%s%%', $query);
|
$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 string $query
|
||||||
|
* @param int $limit
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function searchBill(string $query): Collection;
|
public function searchBill(string $query, int $limit): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
|
@@ -235,7 +235,7 @@ class Search implements SearchInterface
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'bill':
|
case 'bill':
|
||||||
$result = $this->billRepository->searchBill($modifier['value']);
|
$result = $this->billRepository->searchBill($modifier['value'], 25);
|
||||||
if ($result->count() > 0) {
|
if ($result->count() > 0) {
|
||||||
$collector->setBills($result);
|
$collector->setBills($result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user