More CSV related updates.

This commit is contained in:
James Cole
2016-07-23 21:37:06 +02:00
parent a4a723cfc6
commit 87c0f1d86e
31 changed files with 684 additions and 263 deletions

View File

@@ -74,6 +74,7 @@ class AccountCrud implements AccountCrudInterface
*/
public function find(int $accountId): Account
{
Log::debug('Searching for user ', ['user' => $this->user->id]);
$account = $this->user->accounts()->find($accountId);
if (is_null($account)) {
return new Account;
@@ -82,6 +83,33 @@ class AccountCrud implements AccountCrudInterface
return $account;
}
/**
* @param string $number
* @param array $types
*
* @return Account
*/
public function findByAccountNumber(string $number, array $types): Account
{
$query = $this->user->accounts()
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
->where('account_meta.name', 'accountNumber')
->where('account_meta.data', json_encode($number));
if (count($types) > 0) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
/** @var Collection $accounts */
$accounts = $query->get();
if ($accounts->count() > 0) {
return $accounts->first();
}
return new Account;
}
/**
* @param string $iban
* @param array $types

View File

@@ -53,6 +53,14 @@ interface AccountCrudInterface
*/
public function findByName(string $name, array $types): Account;
/**
* @param string $number
* @param array $types
*
* @return Account
*/
public function findByAccountNumber(string $number, array $types): Account;
/**
* @param array $accountIds
*