Various code cleanup.

This commit is contained in:
James Cole
2021-06-12 19:32:34 +02:00
parent 4614625f82
commit 85204de9aa
31 changed files with 52 additions and 62 deletions

View File

@@ -125,7 +125,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
if (0 !== count($types)) {
if (!empty($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -153,7 +153,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts();
if (0 !== count($types)) {
if (!empty($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
@@ -222,7 +222,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$query = $this->user->accounts();
if (0 !== count($accountIds)) {
if (!empty($accountIds)) {
$query->whereIn('accounts.id', $accountIds);
}
$query->orderBy('accounts.order', 'ASC');
@@ -242,7 +242,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);
$query = $this->user->accounts();
if (0 !== count($types)) {
if (!empty($types)) {
$query->accountTypeIn($types);
}
@@ -253,8 +253,8 @@ class AccountRepository implements AccountRepositoryInterface
}
}
if (0 === count($sort)) {
if (0 !== count($res)) {
if (empty($sort)) {
if (!empty($res)) {
$query->orderBy('accounts.order', 'ASC');
}
$query->orderBy('accounts.active', 'DESC');
@@ -276,7 +276,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role');
}, 'attachments']
);
if (0 !== count($types)) {
if (!empty($types)) {
$query->accountTypeIn($types);
}
$query->where('active', true);
@@ -336,7 +336,7 @@ class AccountRepository implements AccountRepositoryInterface
$query->where('name', 'account_role');
}]
);
if (0 !== count($types)) {
if (!empty($types)) {
$query->accountTypeIn($types);
}
$query->where('active', 0);
@@ -674,7 +674,7 @@ class AccountRepository implements AccountRepositoryInterface
}
}
if (0 !== count($types)) {
if (!empty($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}
@@ -712,7 +712,7 @@ class AccountRepository implements AccountRepositoryInterface
);
}
}
if (0 !== count($types)) {
if (!empty($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}
@@ -791,7 +791,7 @@ class AccountRepository implements AccountRepositoryInterface
}
);
if (0 !== count($types)) {
if (!empty($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$dbQuery->whereIn('account_types.type', $types);
}