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

@@ -556,6 +556,25 @@ class AccountRepository implements AccountRepositoryInterface
return $result;
}
/**
* @param string $query
* @param array $types
*
* @return Collection
*/
public function searchAccount(string $query, array $types): Collection
{
$dbQuery = $this->user->accounts();
$search = sprintf('%%%s%%', $query);
if (\count($types) > 0) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}
$dbQuery->where('name', 'LIKE', $search);
return $dbQuery->get(['accounts.*']);
}
/**
* @param User $user
*/