Moved find() method to new class.

This commit is contained in:
James Cole
2016-10-10 07:12:39 +02:00
parent 7180a40cd8
commit 8ef7c5ac33
14 changed files with 99 additions and 80 deletions

View File

@@ -16,17 +16,9 @@ namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
use DB;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Steam;
/**
@@ -85,6 +77,21 @@ class AccountRepository implements AccountRepositoryInterface
return true;
}
/**
* @param $accountId
*
* @return Account
*/
public function find(int $accountId): Account
{
$account = $this->user->accounts()->find($accountId);
if (is_null($account)) {
return new Account;
}
return $account;
}
/**
* Returns the date of the very first transaction in this account.
*

View File

@@ -14,11 +14,7 @@ declare(strict_types = 1);
namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
/**
* Interface AccountRepositoryInterface
@@ -47,6 +43,13 @@ interface AccountRepositoryInterface
*/
public function destroy(Account $account, Account $moveTo): bool;
/**
* @param int $accountId
*
* @return Account
*/
public function find(int $accountId): Account;
/**
* Returns the date of the very first transaction in this account.
*