diff --git a/app/Models/Account.php b/app/Models/Account.php index 445996ae09..70bdf01323 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -1707,6 +1707,11 @@ class Account extends Eloquent return $this->company->accounts->count() > 1; } + public function getPrimaryAccount() + { + return $this->company->accounts()->orderBy('id')->first(); + } + public function financialYearStart() { if (! $this->financial_year_start) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 50f16160be..21e64a01f8 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2598,6 +2598,7 @@ $LANG = array( 'can_view_tasks' => 'Tasks are visible in the portal', 'is_not_sent_reminders' => 'Reminders are not sent', 'promotion_footer' => 'Your promotion will expire soon, :link to upgrade now.', + 'unable_to_delete_primary' => 'Note: to delete this company first delete all linked companies.', ); diff --git a/resources/views/accounts/management.blade.php b/resources/views/accounts/management.blade.php index ec4ea2cfa3..f251365de7 100644 --- a/resources/views/accounts/management.blade.php +++ b/resources/views/accounts/management.blade.php @@ -273,39 +273,48 @@ {!! Former::close() !!} - {!! Former::open('settings/cancel_account')->addClass('cancel-account') !!} - {!! Former::actions( Button::danger($account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account'))->large()->withAttributes(['onclick' => 'showCancelConfirm()'])->appendIcon(Icon::create('trash'))) !!} -