Moved getAccountsById

This commit is contained in:
James Cole
2016-10-10 07:25:27 +02:00
parent 717c1d080e
commit e8a095e543
8 changed files with 52 additions and 47 deletions

View File

@@ -178,6 +178,30 @@ class AccountRepository implements AccountRepositoryInterface
return new Account;
}
/**
* @param array $accountIds
*
* @return Collection
*/
public function getAccountsById(array $accountIds): Collection
{
/** @var Collection $result */
$query = $this->user->accounts();
if (count($accountIds) > 0) {
$query->whereIn('accounts.id', $accountIds);
}
$result = $query->get(['accounts.*']);
$result = $result->sortBy(
function (Account $account) {
return strtolower($account->name);
}
);
return $result;
}
/**
* Returns the date of the very first transaction in this account.
*

View File

@@ -15,6 +15,7 @@ namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use Illuminate\Support\Collection;
/**
* Interface AccountRepositoryInterface
@@ -33,6 +34,13 @@ interface AccountRepositoryInterface
*/
public function count(array $types): int;
/**
* @param array $accountIds
*
* @return Collection
*/
public function getAccountsById(array $accountIds): Collection;
/**
* @param string $name
* @param array $types