mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix various code.
This commit is contained in:
@@ -212,7 +212,7 @@ class FireflyValidator extends Validator
|
||||
// take
|
||||
$first = substr($value, 0, 4);
|
||||
$last = substr($value, 4);
|
||||
$iban = $last . $first;
|
||||
$iban = $last.$first;
|
||||
$iban = trim(str_replace($search, $replace, $iban));
|
||||
if ('' === $iban) {
|
||||
return false;
|
||||
@@ -507,10 +507,11 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
|
||||
$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->whereNull('accounts.deleted_at')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->where('account_meta.name', 'account_number')
|
||||
->where('account_meta.data', json_encode($value));
|
||||
->whereNull('accounts.deleted_at')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->where('account_meta.name', 'account_number')
|
||||
->where('account_meta.data', json_encode($value))
|
||||
;
|
||||
|
||||
if ($accountId > 0) {
|
||||
// exclude current account from check.
|
||||
@@ -552,7 +553,7 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function validateUniqueCurrencyCode(null | string $attribute, null | string $value): bool
|
||||
public function validateUniqueCurrencyCode(null|string $attribute, null|string $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('code', (string) $attribute, (string) $value);
|
||||
}
|
||||
@@ -565,12 +566,12 @@ class FireflyValidator extends Validator
|
||||
return 0 === \DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
|
||||
}
|
||||
|
||||
public function validateUniqueCurrencyName(null | string $attribute, null | string $value): bool
|
||||
public function validateUniqueCurrencyName(null|string $attribute, null|string $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
|
||||
}
|
||||
|
||||
public function validateUniqueCurrencySymbol(null | string $attribute, null | string $value): bool
|
||||
public function validateUniqueCurrencySymbol(null|string $attribute, null|string $value): bool
|
||||
{
|
||||
return $this->validateUniqueCurrency('symbol', (string) $attribute, (string) $value);
|
||||
}
|
||||
@@ -613,11 +614,12 @@ class FireflyValidator extends Validator
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
return 0 === Webhook::whereUserId($userId)
|
||||
->where('trigger', $trigger)
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('id', '!=', $existingId)
|
||||
->where('url', $url)->count();
|
||||
->where('trigger', $trigger)
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('id', '!=', $existingId)
|
||||
->where('url', $url)->count()
|
||||
;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -651,9 +653,10 @@ class FireflyValidator extends Validator
|
||||
}
|
||||
// get entries from table
|
||||
$result = \DB::table($table)->where('user_id', auth()->user()->id)->whereNull('deleted_at')
|
||||
->where('id', '!=', $exclude)
|
||||
->where($field, $value)
|
||||
->first([$field]);
|
||||
->where('id', '!=', $exclude)
|
||||
->where($field, $value)
|
||||
->first([$field])
|
||||
;
|
||||
if (null === $result) {
|
||||
return true; // not found, so true.
|
||||
}
|
||||
@@ -673,9 +676,10 @@ class FireflyValidator extends Validator
|
||||
{
|
||||
$exclude = $parameters[0] ?? null;
|
||||
$query = \DB::table('object_groups')
|
||||
->whereNull('object_groups.deleted_at')
|
||||
->where('object_groups.user_id', auth()->user()->id)
|
||||
->where('object_groups.title', $value);
|
||||
->whereNull('object_groups.deleted_at')
|
||||
->where('object_groups.user_id', auth()->user()->id)
|
||||
->where('object_groups.title', $value)
|
||||
;
|
||||
if (null !== $exclude) {
|
||||
$query->where('object_groups.id', '!=', (int) $exclude);
|
||||
}
|
||||
@@ -694,7 +698,8 @@ class FireflyValidator extends Validator
|
||||
{
|
||||
$exclude = $parameters[0] ?? null;
|
||||
$query = \DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id);
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id)
|
||||
;
|
||||
if (null !== $exclude) {
|
||||
$query->where('piggy_banks.id', '!=', (int) $exclude);
|
||||
}
|
||||
@@ -724,10 +729,11 @@ class FireflyValidator extends Validator
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
return 0 === Webhook::whereUserId($userId)
|
||||
->where('trigger', $trigger)
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('url', $url)->count();
|
||||
->where('trigger', $trigger)
|
||||
->where('response', $response)
|
||||
->where('delivery', $delivery)
|
||||
->where('url', $url)->count()
|
||||
;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -753,7 +759,7 @@ class FireflyValidator extends Validator
|
||||
private function validateByAccountTypeString(string $value, array $parameters, string $type): bool
|
||||
{
|
||||
/** @var null|array $search */
|
||||
$search = \Config::get('firefly.accountTypeByIdentifier.' . $type);
|
||||
$search = \Config::get('firefly.accountTypeByIdentifier.'.$type);
|
||||
|
||||
if (null === $search) {
|
||||
return false;
|
||||
@@ -765,8 +771,9 @@ class FireflyValidator extends Validator
|
||||
|
||||
/** @var null|Account $result */
|
||||
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
@@ -782,8 +789,9 @@ class FireflyValidator extends Validator
|
||||
|
||||
/** @var null|Account $result */
|
||||
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $result;
|
||||
}
|
||||
@@ -800,8 +808,9 @@ class FireflyValidator extends Validator
|
||||
$ignore = $existingAccount->id;
|
||||
|
||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $entry;
|
||||
}
|
||||
@@ -818,8 +827,9 @@ class FireflyValidator extends Validator
|
||||
$ignore = $existingAccount->id;
|
||||
|
||||
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
|
||||
->where('name', $value)
|
||||
->first();
|
||||
->where('name', $value)
|
||||
->first()
|
||||
;
|
||||
|
||||
return null === $entry;
|
||||
}
|
||||
|
Reference in New Issue
Block a user