chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -41,8 +41,8 @@ class UniqueIban implements ValidationRule
* 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)
{
@@ -78,11 +78,21 @@ class UniqueIban implements ValidationRule
return (string)trans('validation.unique_iban_for_user');
}
/**
* @inheritDoc
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->passes($attribute, $value)) {
$fail((string)trans('validation.unique_iban_for_user'));
}
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @param string $attribute
* @param mixed $value
*
* @return bool
*
@@ -118,42 +128,6 @@ class UniqueIban implements ValidationRule
return true;
}
/**
* @inheritDoc
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->passes($attribute, $value)) {
$fail((string)trans('validation.unique_iban_for_user'));
}
}
/**
* @param string $type
* @param string $iban
*
* @return int
*/
private function countHits(string $type, string $iban): int
{
$typesArray = [$type];
if ('liabilities' === $type) {
$typesArray = [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
}
$query
= auth()->user()
->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where('accounts.iban', $iban)
->whereIn('account_types.type', $typesArray);
if (null !== $this->account) {
$query->where('accounts.id', '!=', $this->account->id);
}
return $query->count();
}
/**
* @return array
*
@@ -180,4 +154,30 @@ class UniqueIban implements ValidationRule
return $maxCounts;
}
/**
* @param string $type
* @param string $iban
*
* @return int
*/
private function countHits(string $type, string $iban): int
{
$typesArray = [$type];
if ('liabilities' === $type) {
$typesArray = [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
}
$query
= auth()->user()
->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where('accounts.iban', $iban)
->whereIn('account_types.type', $typesArray);
if (null !== $this->account) {
$query->where('accounts.id', '!=', $this->account->id);
}
return $query->count();
}
}