Code cleanup

This commit is contained in:
James Cole
2021-03-21 09:15:40 +01:00
parent da1751940e
commit 206845575c
317 changed files with 7418 additions and 7362 deletions

View File

@@ -35,7 +35,7 @@ use Log;
class UniqueAccountNumber implements Rule
{
private ?Account $account;
private ?string $expectedType;
private ?string $expectedType;
/**
* Create a new rule instance.
@@ -109,32 +109,10 @@ class UniqueAccountNumber implements Rule
}
}
Log::debug('Account number is valid.');
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
*
@@ -160,4 +138,27 @@ 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();
}
}