Fixed double named accounts.

This commit is contained in:
James Cole
2015-03-26 18:05:23 +01:00
parent 3d59d141c4
commit e0730c7b39
4 changed files with 49 additions and 7 deletions

View File

@@ -285,12 +285,14 @@ class AccountRepository implements AccountRepositoryInterface
'active' => $data['active'] === true ? true : false,
]
);
if (!$newAccount->isValid()) {
// does the account already exist?
$existingAccount = Account::where('user_id', $data['user'])->where('account_type_id', $accountType->id)->where('name', $data['name'])->first();
if (!$existingAccount) {
Log::error('Account create error: ' . $newAccount->getErrors()->toJson());
var_dump($newAccount->getErrors()->toArray());
App::abort(500);
}
$newAccount = $existingAccount;
}