James Cole 2024-10-10 06:30:05 +02:00
parent 562763c938
commit b41fc43e64
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
23 changed files with 60 additions and 59 deletions

View File

@ -126,7 +126,7 @@ class BillFactory
public function findByName(string $name): ?Bill
{
return $this->user->bills()->where('name', 'LIKE', sprintf('%%%s%%', $name))->first();
return $this->user->bills()->whereLike('name', sprintf('%%%s%%', $name))->first();
}
public function setUser(User $user): void

View File

@ -221,7 +221,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $externalId));
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $externalId));
return $this;
}
@ -257,7 +257,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
$this->query->whereLike('journal_meta.data', sprintf('"%s%%', $externalId));
return $this;
}
@ -269,7 +269,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $externalId));
$this->query->whereLike('journal_meta.data', sprintf('%%%s"', $externalId));
return $this;
}
@ -281,7 +281,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $externalId));
$this->query->whereLike('journal_meta.data', sprintf('"%s%%', $externalId));
return $this;
}
@ -292,7 +292,7 @@ trait MetaCollection
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $url));
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
return $this;
}
@ -338,7 +338,7 @@ trait MetaCollection
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s', $url));
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
return $this;
}
@ -351,7 +351,7 @@ trait MetaCollection
// var_dump($url);
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%s%%', $url));
$this->query->whereLike('journal_meta.data', sprintf('%s%%', $url));
return $this;
}
@ -404,7 +404,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $internalReference));
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $internalReference));
return $this;
}
@ -440,7 +440,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $internalReference));
$this->query->whereLike('journal_meta.data', sprintf('"%s%%', $internalReference));
return $this;
}
@ -452,7 +452,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s"', $internalReference));
$this->query->whereLike('journal_meta.data', sprintf('%%%s"', $internalReference));
return $this;
}
@ -464,7 +464,7 @@ trait MetaCollection
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', 'LIKE', sprintf('"%s%%', $internalReference));
$this->query->whereLike('journal_meta.data', sprintf('"%s%%', $internalReference));
return $this;
}
@ -472,7 +472,7 @@ trait MetaCollection
public function notesContain(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where('notes.text', 'LIKE', sprintf('%%%s%%', $value));
$this->query->whereLike('notes.text', sprintf('%%%s%%', $value));
return $this;
}
@ -533,7 +533,7 @@ trait MetaCollection
public function notesEndWith(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where('notes.text', 'LIKE', sprintf('%%%s', $value));
$this->query->whereLike('notes.text', sprintf('%%%s', $value));
return $this;
}
@ -560,7 +560,7 @@ trait MetaCollection
public function notesStartWith(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where('notes.text', 'LIKE', sprintf('%s%%', $value));
$this->query->whereLike('notes.text', sprintf('%s%%', $value));
return $this;
}

View File

@ -210,7 +210,7 @@ class GroupCollector implements GroupCollectorInterface
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
$q1->whereLike('transaction_journals.description', $keyword);
}
}
);
@ -218,7 +218,7 @@ class GroupCollector implements GroupCollectorInterface
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
$q2->whereLike('transaction_groups.title', $keyword);
}
}
);
@ -265,7 +265,7 @@ class GroupCollector implements GroupCollectorInterface
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%s%%', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
$q1->whereLike('transaction_journals.description', $keyword);
}
}
);
@ -273,7 +273,7 @@ class GroupCollector implements GroupCollectorInterface
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%s%%', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
$q2->whereLike('transaction_groups.title', $keyword);
}
}
);
@ -944,7 +944,7 @@ class GroupCollector implements GroupCollectorInterface
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
$q1->whereLike('transaction_journals.description', $keyword);
}
}
);
@ -952,7 +952,7 @@ class GroupCollector implements GroupCollectorInterface
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
$q2->whereLike('transaction_groups.title', $keyword);
}
}
);

View File

@ -576,7 +576,7 @@ class AccountRepository implements AccountRepositoryInterface
$parts = explode(' ', $query);
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$dbQuery->where('name', 'LIKE', $search);
$dbQuery->whereLike('name', $search);
}
}
if (0 !== count($types)) {
@ -604,11 +604,11 @@ class AccountRepository implements AccountRepositoryInterface
$search = sprintf('%%%s%%', $part);
$dbQuery->where(
static function (EloquentBuilder $q1) use ($search): void { // @phpstan-ignore-line
$q1->where('accounts.iban', 'LIKE', $search);
$q1->whereLike('accounts.iban', $search);
$q1->orWhere(
static function (EloquentBuilder $q2) use ($search): void {
$q2->where('account_meta.name', '=', 'account_number');
$q2->where('account_meta.data', 'LIKE', $search);
$q2->whereLike('account_meta.data', $search);
}
);
}

View File

@ -57,7 +57,7 @@ class BillRepository implements BillRepositoryInterface
{
$search = $this->user->bills();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%%%s', $query));
$search->whereLike('name', sprintf('%%%s', $query));
}
$search->orderBy('name', 'ASC')
->where('active', true)
@ -70,7 +70,7 @@ class BillRepository implements BillRepositoryInterface
{
$search = $this->user->bills();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%s%%', $query));
$search->whereLike('name', sprintf('%s%%', $query));
}
$search->orderBy('name', 'ASC')
->where('active', true)
@ -485,7 +485,7 @@ class BillRepository implements BillRepositoryInterface
{
$query = sprintf('%%%s%%', $query);
return $this->user->bills()->where('name', 'LIKE', $query)->take($limit)->get();
return $this->user->bills()->whereLike('name', $query)->take($limit)->get();
}
public function setObjectGroup(Bill $bill, string $objectGroupTitle): Bill

View File

@ -57,7 +57,7 @@ class BudgetRepository implements BudgetRepositoryInterface
{
$search = $this->user->budgets();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%%%s', $query));
$search->whereLike('name', sprintf('%%%s', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', true)
@ -70,7 +70,7 @@ class BudgetRepository implements BudgetRepositoryInterface
{
$search = $this->user->budgets();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%s%%', $query));
$search->whereLike('name', sprintf('%s%%', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', true)
@ -512,7 +512,7 @@ class BudgetRepository implements BudgetRepositoryInterface
}
$query = sprintf('%%%s%%', $name);
return $this->user->budgets()->where('name', 'LIKE', $query)->first();
return $this->user->budgets()->whereLike('name', $query)->first();
}
/**
@ -577,7 +577,7 @@ class BudgetRepository implements BudgetRepositoryInterface
{
$search = $this->user->budgets();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%%%s%%', $query));
$search->whereLike('name', sprintf('%%%s%%', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', true)

View File

@ -49,7 +49,7 @@ class CategoryRepository implements CategoryRepositoryInterface
{
$search = $this->user->categories();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%%%s', $query));
$search->whereLike('name', sprintf('%%%s', $query));
}
return $search->take($limit)->get();
@ -59,7 +59,7 @@ class CategoryRepository implements CategoryRepositoryInterface
{
$search = $this->user->categories();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%s%%', $query));
$search->whereLike('name', sprintf('%s%%', $query));
}
return $search->take($limit)->get();
@ -344,7 +344,7 @@ class CategoryRepository implements CategoryRepositoryInterface
{
$search = $this->user->categories();
if ('' !== $query) {
$search->where('name', 'LIKE', sprintf('%%%s%%', $query));
$search->whereLike('name', sprintf('%%%s%%', $query));
}
return $search->take($limit)->get();

View File

@ -197,7 +197,7 @@ class JournalRepository implements JournalRepositoryInterface
->orderBy('date', 'DESC')
;
if ('' !== $search) {
$query->where('description', 'LIKE', sprintf('%%%s%%', $search));
$query->whereLike('description', sprintf('%%%s%%', $search));
}
return $query->take($limit)->get();

View File

@ -120,7 +120,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
$parts = explode(' ', $query);
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$dbQuery->where('title', 'LIKE', $search);
$dbQuery->whereLike('title', $search);
}
}

View File

@ -343,7 +343,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
{
$search = $this->user->piggyBanks();
if ('' !== $query) {
$search->where('piggy_banks.name', 'LIKE', sprintf('%%%s%%', $query));
$search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query));
}
$search->orderBy('piggy_banks.order', 'ASC')
->orderBy('piggy_banks.name', 'ASC')

View File

@ -496,7 +496,7 @@ class RecurringRepository implements RecurringRepositoryInterface
{
$search = $this->user->recurrences();
if ('' !== $query) {
$search->where('recurrences.title', 'LIKE', sprintf('%%%s%%', $query));
$search->whereLike('recurrences.title', sprintf('%%%s%%', $query));
}
$search
->orderBy('recurrences.title', 'ASC')

View File

@ -213,7 +213,7 @@ class RuleRepository implements RuleRepositoryInterface
{
$search = $this->user->rules();
if ('' !== $query) {
$search->where('rules.title', 'LIKE', sprintf('%%%s%%', $query));
$search->whereLike('rules.title', sprintf('%%%s%%', $query));
}
$search->orderBy('rules.order', 'ASC')
->orderBy('rules.title', 'ASC')

View File

@ -371,7 +371,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
{
$search = $this->user->ruleGroups();
if ('' !== $query) {
$search->where('rule_groups.title', 'LIKE', sprintf('%%%s%%', $query));
$search->whereLike('rule_groups.title', sprintf('%%%s%%', $query));
}
$search->orderBy('rule_groups.order', 'ASC')
->orderBy('rule_groups.title', 'ASC')

View File

@ -205,7 +205,7 @@ class TagRepository implements TagRepositoryInterface
{
$search = sprintf('%%%s%%', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
return $this->user->tags()->whereLike('tag', $search)->get(['tags.*']);
}
/**
@ -217,7 +217,7 @@ class TagRepository implements TagRepositoryInterface
$tags = $this->user->tags()->orderBy('tag', 'ASC');
if ('' !== $query) {
$search = sprintf('%%%s%%', $query);
$tags->where('tag', 'LIKE', $search);
$tags->whereLike('tag', $search);
}
return $tags->take($limit)->get('tags.*');
@ -309,14 +309,14 @@ class TagRepository implements TagRepositoryInterface
{
$search = sprintf('%%%s', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
return $this->user->tags()->whereLike('tag', $search)->get(['tags.*']);
}
public function tagStartsWith(string $query): Collection
{
$search = sprintf('%s%%', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
return $this->user->tags()->whereLike('tag', $search)->get(['tags.*']);
}
public function transferredInPeriod(Tag $tag, Carbon $start, Carbon $end): array

View File

@ -62,6 +62,6 @@ class TransactionTypeRepository implements TransactionTypeRepositoryInterface
return TransactionType::get();
}
return TransactionType::where('type', 'LIKE', sprintf('%%%s%%', $query))->take($limit)->get();
return TransactionType::whereLike('type', sprintf('%%%s%%', $query))->take($limit)->get();
}
}

View File

@ -270,7 +270,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('accounts.active', $value);
}
if ('name' === $column) {
$query->where('accounts.name', 'LIKE', sprintf('%%%s%%', $value));
$query->whereLike('accounts.name', sprintf('%%%s%%', $value));
}
}
@ -315,7 +315,7 @@ class AccountRepository implements AccountRepositoryInterface
$parts = explode(' ', $line);
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$q->orWhere('name', 'LIKE', $search);
$q->orWhereLike('name', $search);
}
}
});

View File

@ -41,7 +41,7 @@ class CategoryRepository implements CategoryRepositoryInterface
$parts = explode(' ', $line);
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$q->orWhere('name', 'LIKE', $search);
$q->orWhereLike('name', $search);
}
}
});

View File

@ -320,7 +320,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
{
$query = TransactionCurrency::where('enabled', true);
if ('' !== $search) {
$query->where('name', 'LIKE', sprintf('%%%s%%', $search));
$query->whereLike('name', sprintf('%%%s%%', $search));
}
return $query->take($limit)->get();

View File

@ -46,7 +46,7 @@ class JournalRepository implements JournalRepositoryInterface
$parts = explode(' ', $line);
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$q->orWhere('description', 'LIKE', $search);
$q->orWhereLike('description', $search);
}
}
});

View File

@ -44,7 +44,7 @@ class TagRepository implements TagRepositoryInterface
$parts = explode(' ', $line);
foreach ($parts as $part) {
$search = sprintf('%%%s%%', $part);
$q->orWhere('tag', 'LIKE', $search);
$q->orWhereLike('tag', $search);
}
}
});

View File

@ -120,7 +120,7 @@ trait ExpandsQuery
Log::debug(sprintf('Add query filter "%s"', $key));
// add type to query:
foreach ($filter as $value) {
$q->where($key, 'LIKE', sprintf('%%%s%%', $value));
$q->whereLike($key, sprintf('%%%s%%', $value));
}
}
}

View File

@ -151,7 +151,8 @@ class Preferences
public function beginsWith(User $user, string $search): Collection
{
return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search.'%')->get();
$value = sprintf('%s%%', $search);
return Preference::where('user_id', $user->id)->whereLike('name', $value)->get();
}
/**

View File

@ -73,9 +73,9 @@ class AccountSearch implements GenericSearchInterface
case self::SEARCH_ALL:
$searchQuery->where(
static function (Builder $q) use ($like): void { // @phpstan-ignore-line
$q->where('accounts.id', 'LIKE', $like);
$q->orWhere('accounts.name', 'LIKE', $like);
$q->orWhere('accounts.iban', 'LIKE', $like);
$q->whereLike('accounts.id', $like);
$q->orWhereLike('accounts.name', $like);
$q->orWhereLike('accounts.iban', $like);
}
);
// meta data:
@ -83,7 +83,7 @@ class AccountSearch implements GenericSearchInterface
static function (Builder $q) use ($originalQuery): void { // @phpstan-ignore-line
$json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', '=', 'account_number');
$q->where('account_meta.data', 'LIKE', $json);
$q->whereLike('account_meta.data', $json);
}
);
@ -95,12 +95,12 @@ class AccountSearch implements GenericSearchInterface
break;
case self::SEARCH_NAME:
$searchQuery->where('accounts.name', 'LIKE', $like);
$searchQuery->whereLike('accounts.name', $like);
break;
case self::SEARCH_IBAN:
$searchQuery->where('accounts.iban', 'LIKE', $like);
$searchQuery->whereLike('accounts.iban', $like);
break;