Fix for deleting account

This commit is contained in:
Hillel Coren 2016-05-17 15:03:17 +03:00
parent e5e65c0349
commit faec0a2f04
2 changed files with 26 additions and 25 deletions

View File

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

View File

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