diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index e98034e5e347..abf0ff5565ac 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -46,6 +46,7 @@ use Utils; use Validator; use View; +use App\Jobs\PurgeClientData; /** * Class AccountController. @@ -389,7 +390,9 @@ class AccountController extends BaseController $planDetails = $account->getPlanDetails(true); $portalLink = false; - if (Utils::isNinja() && $planDetails && $ninjaClient = $this->accountRepo->getNinjaClient($account)) { + if (Utils::isNinja() && $planDetails + && $account->getPrimaryAccount()->id == auth()->user()->account_id + && $ninjaClient = $this->accountRepo->getNinjaClient($account)) { $contact = $ninjaClient->getPrimaryContact(); $portalLink = $contact->link; } @@ -1459,7 +1462,7 @@ class AccountController extends BaseController $refunded = $company->processRefund(Auth::user()); $ninjaClient = $this->accountRepo->getNinjaClient($account); - $ninjaClient->delete(); + dispatch(new \App\Jobs\PurgeClientData($ninjaClient)); } Document::scope()->each(function ($item, $key) { diff --git a/database/migrations/2018_03_08_150414_add_slack_notifications.php b/database/migrations/2018_03_08_150414_add_slack_notifications.php index fc3e64651cd2..0a6eb4565b6e 100644 --- a/database/migrations/2018_03_08_150414_add_slack_notifications.php +++ b/database/migrations/2018_03_08_150414_add_slack_notifications.php @@ -46,6 +46,30 @@ class AddSlackNotifications extends Migration $table->foreign('invitation_id')->references('id')->on('invitations')->onDelete('cascade'); $table->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade'); }); + + Schema::table('companies', function ($table) { + $table->dropForeign('companies_payment_id_foreign'); + }); + + Schema::table('companies', function ($table) { + $table->index('payment_id'); + }); + + Schema::table('user_accounts', function ($table) { + $table->dropForeign('user_accounts_user_id1_foreign'); + $table->dropForeign('user_accounts_user_id2_foreign'); + $table->dropForeign('user_accounts_user_id3_foreign'); + $table->dropForeign('user_accounts_user_id4_foreign'); + $table->dropForeign('user_accounts_user_id5_foreign'); + }); + + Schema::table('user_accounts', function ($table) { + $table->index('user_id1'); + $table->index('user_id2'); + $table->index('user_id3'); + $table->index('user_id4'); + $table->index('user_id5'); + }); } /**