Fix for deleting account

This commit is contained in:
Hillel Coren 2016-05-17 15:05:07 +03:00
parent 3ed5fdf09f
commit 861672e9e9
2 changed files with 27 additions and 26 deletions

View File

@ -1254,8 +1254,9 @@ class AccountController extends BaseController
$this->accountRepo->unlinkAccount($account);
if ($account->company->accounts->count() == 1) {
$account->company->forceDelete();
} else {
$account->forceDelete();
}
$account->forceDelete();
Auth::logout();
Session::flush();

View File

@ -49,7 +49,7 @@ class EnterprisePlan extends Migration
Schema::table('accounts', function($table)
{
$table->unsignedInteger('company_id')->nullable();
$table->foreign('company_id')->references('id')->on('companies');
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
});
}