mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-11 07:10:48 +00:00
chore: reformat code.
This commit is contained in:
@@ -41,8 +41,8 @@ class UniqueAccountNumber implements Rule
|
||||
* Create a new rule instance.
|
||||
*
|
||||
*
|
||||
* @param Account|null $account
|
||||
* @param string|null $expectedType
|
||||
* @param Account|null $account
|
||||
* @param string|null $expectedType
|
||||
*/
|
||||
public function __construct(?Account $account, ?string $expectedType)
|
||||
{
|
||||
@@ -76,8 +76,8 @@ class UniqueAccountNumber implements Rule
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
@@ -114,28 +114,6 @@ 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
|
||||
*
|
||||
@@ -161,4 +139,26 @@ 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