mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 01:41:14 -06:00
Account controller #185
This commit is contained in:
parent
1aea4045a3
commit
919aa70251
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user