Search improvements.

This commit is contained in:
James Cole
2019-03-02 14:12:09 +01:00
parent af07522f16
commit 87d5cabe52
16 changed files with 226 additions and 37 deletions

View File

@@ -531,6 +531,18 @@ class CategoryRepository implements CategoryRepositoryInterface
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param string $query
*
* @return Collection
*/
public function searchCategory(string $query): Collection
{
$query = sprintf('%%%s%%', $query);
return $this->user->categories()->where('name', 'LIKE', $query)->get();
}
/**
* @param User $user
*/

View File

@@ -40,7 +40,6 @@ interface CategoryRepositoryInterface
*/
public function destroy(Category $category): bool;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@@ -52,6 +51,7 @@ interface CategoryRepositoryInterface
public function earnedInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@@ -62,6 +62,8 @@ interface CategoryRepositoryInterface
*/
public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* A very cryptic method name that means:
*
@@ -119,8 +121,6 @@ interface CategoryRepositoryInterface
*/
public function getByIds(array $categoryIds): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Returns a list of all the categories belonging to a user.
*
@@ -128,6 +128,8 @@ interface CategoryRepositoryInterface
*/
public function getCategories(): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Return most recent transaction(journal) date or null when never used before.
*
@@ -138,8 +140,6 @@ interface CategoryRepositoryInterface
*/
public function lastUseDate(Category $category, Collection $accounts): ?Carbon;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@@ -150,6 +150,8 @@ interface CategoryRepositoryInterface
*/
public function periodExpenses(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $accounts
* @param Carbon $start
@@ -169,8 +171,6 @@ interface CategoryRepositoryInterface
*/
public function periodIncome(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $accounts
* @param Carbon $start
@@ -182,6 +182,15 @@ interface CategoryRepositoryInterface
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param string $query
*
* @return Collection
*/
public function searchCategory(string $query): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param User $user
*/