Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Account controller #185
James Cole919aa70251fe
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex b9ed2fd939..11069ba57a 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -87,7 +87,7 @@ class AccountController extends Controller$type = $account->accountType->type;$typeName = Config::get('firefly.shortNamesByFullName.' . $type);$name = $account->name;- $moveTo = Auth::user()->accounts()->find(intval(Input::get('move_account_before_delete')));+ $moveTo = $repository->find(intval(Input::get('move_account_before_delete')));$repository->destroy($account, $moveTo);diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 8f2747edd8..64ffdca545 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -66,9 +66,9 @@ class AccountRepository implements AccountRepositoryInterface** @return bool*/- public function destroy(Account $account, Account $moveTo = null): bool+ public function destroy(Account $account, Account $moveTo): bool{- if (!is_null($moveTo)) {+ if (!is_null($moveTo->id)) {// update all transactions:DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);}@@ -79,15 +79,16 @@ class AccountRepository implements AccountRepositoryInterface}/**- * @deprecated- ** @param int $accountId** @return Account*/public function find(int $accountId): Account{- return $this->user->accounts()->findOrNew($accountId);+ $entry = $this->user->accounts()->find($accountId);+ if (is_null($entry)) {+ return new Account;+ }}/**diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.phpindex 8bc25e8485..cd2b8520a5 100644--- a/app/Repositories/Account/AccountRepositoryInterface.php+++ b/app/Repositories/Account/AccountRepositoryInterface.php@@ -32,13 +32,11 @@ interface AccountRepositoryInterface** @return boolean*/- public function destroy(Account $account, Account $moveTo = null): bool;+ public function destroy(Account $account, Account $moveTo): bool;/*** @param int $accountId*- * @deprecated- ** @return Account*/public function find(int $accountId): Account;