mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
chore: code cleanup.
This commit is contained in:
@@ -114,6 +114,28 @@ class UniqueAccountNumber implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $accountNumber
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function countHits(string $type, string $accountNumber): int
|
||||
{
|
||||
$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->where('account_types.type', $type)
|
||||
->where('account_meta.name', '=', 'account_number')
|
||||
->where('account_meta.data', json_encode($accountNumber));
|
||||
|
||||
if (null !== $this->account) {
|
||||
$query->where('accounts.id', '!=', $this->account->id);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
@@ -139,26 +161,4 @@ class UniqueAccountNumber implements Rule
|
||||
|
||||
return $maxCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $accountNumber
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function countHits(string $type, string $accountNumber): int
|
||||
{
|
||||
$query = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('accounts.user_id', auth()->user()->id)
|
||||
->where('account_types.type', $type)
|
||||
->where('account_meta.name', '=', 'account_number')
|
||||
->where('account_meta.data', json_encode($accountNumber));
|
||||
|
||||
if (null !== $this->account) {
|
||||
$query->where('accounts.id', '!=', $this->account->id);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user