diff --git a/CHANGELOG b/CHANGELOG index 965be645d..0c8d2b98e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ UNRELEASED CHANGES: +* Fix reset account deleting default account values * Fix notifications not working with aysnchronous queue * Support mysql unix socket diff --git a/app/Account.php b/app/Account.php index e6f02e6bc..e7362e2da 100644 --- a/app/Account.php +++ b/app/Account.php @@ -49,9 +49,7 @@ class Account extends Model $account->created_at = Carbon::now(); $account->save(); - $account->populateContactFieldTypeTable(); - $account->populateDefaultGendersTable(); - $account->populateDefaultReminderRulesTable(); + $account->populateDefaultFields($account); // create the first user for this account User::createDefault($account->id, $first_name, $last_name, $email, $password); @@ -59,6 +57,17 @@ class Account extends Model return $account; } + /** + * Populates all the default column that should be there when a new account + * is created or reset. + */ + public static function populateDefaultFields($account) + { + $account->populateContactFieldTypeTable(); + $account->populateDefaultGendersTable(); + $account->populateDefaultReminderRulesTable(); + } + /** * Get the activity records associated with the account. * diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 1ddcc1083..ac3a12b7a 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -149,6 +149,8 @@ class SettingsController extends Controller DB::table($tableName)->where('account_id', $account->id)->delete(); } + $account->populateDefaultFields($account); + return redirect('/settings') ->with('status', trans('settings.reset_success')); }