Expand search

This commit is contained in:
James Cole
2022-03-20 17:11:33 +01:00
parent ba10aa5ca5
commit 02687dfe53
17 changed files with 827 additions and 388 deletions

View File

@@ -782,4 +782,35 @@ class BillRepository implements BillRepositoryInterface
return $service->update($bill, $data);
}
/**
* @inheritDoc
*/
public function billEndsWith(string $query, int $limit): Collection
{
$search = $this->user->bills();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%%%s', $query));
}
$search->orderBy('name', 'ASC')
->where('active', true);
return $search->take($limit)->get();
}
/**
* @inheritDoc
*/
public function billStartsWith(string $query, int $limit): Collection
{
$search = $this->user->bills();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%s%%', $query));
}
$search->orderBy('name', 'ASC')
->where('active', true);
return $search->take($limit)->get();
}
}

View File

@@ -40,6 +40,22 @@ interface BillRepositoryInterface
*/
public function correctOrder(): void;
/**
* @param string $query
* @param int $limit
*
* @return Collection
*/
public function billEndsWith(string $query, int $limit): Collection;
/**
* @param string $query
* @param int $limit
*
* @return Collection
*/
public function billStartsWith(string $query, int $limit): Collection;
/**
* @param Bill $bill
*