From 197f9f9e3a7c11eb7c58961a9f2e1f8da0c6ffe8 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Thu, 13 Feb 2020 16:09:24 +0300 Subject: [PATCH 1/2] prevent disable active company --- app/Jobs/Common/UpdateCompany.php | 7 +++++++ resources/lang/en-GB/companies.php | 1 + 2 files changed, 8 insertions(+) diff --git a/app/Jobs/Common/UpdateCompany.php b/app/Jobs/Common/UpdateCompany.php index b5fbe610b..e376a4c47 100644 --- a/app/Jobs/Common/UpdateCompany.php +++ b/app/Jobs/Common/UpdateCompany.php @@ -89,6 +89,13 @@ class UpdateCompany extends Job */ public function authorize() { + // Can't disable active company + if (($this->request->get('enabled', 1) == 0) && ($this->company->id == session('company_id'))) { + $message = trans('companies.error.disable_active'); + + throw new \Exception($message); + } + // Check if user can access company if (!$this->isUserCompany($this->company->id)) { $message = trans('companies.error.not_user_company'); diff --git a/resources/lang/en-GB/companies.php b/resources/lang/en-GB/companies.php index 8415b2f8b..44e97402c 100644 --- a/resources/lang/en-GB/companies.php +++ b/resources/lang/en-GB/companies.php @@ -8,6 +8,7 @@ return [ 'error' => [ 'not_user_company' => 'Error: You are not allowed to change this company!', 'delete_active' => 'Error: Can not delete the active company. Please, switch to another first!', + 'disable_active' => 'Error: Can not disable the active company. Please, switch to another first!', ], ]; From 72fd4a905536512fb3082f73fcfbfada499ae855 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Thu, 13 Feb 2020 16:09:51 +0300 Subject: [PATCH 2/2] changed go to dashboard text --- resources/lang/en-GB/general.php | 2 +- resources/views/errors/403.blade.php | 2 +- resources/views/errors/404.blade.php | 2 +- resources/views/errors/500.blade.php | 2 +- resources/views/wizard/finish/index.blade.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index b078f2993..7c3426789 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -128,7 +128,6 @@ return [ 'disable' => 'Disable', 'select_all' => 'Select All', 'unselect_all' => 'Unselect All', - 'go_to' => 'Go to :name', 'created_date' => 'Created Date', 'period' => 'Period', 'frequency' => 'Frequency', @@ -152,6 +151,7 @@ return [ 'no_data' => 'No data', 'no_matching_data' => 'No matching data', 'clear_cache' => 'Clear Cache', + 'go_to_dashboard' => 'Go to dashboard', 'card' => [ 'name' => 'Name on Card', diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php index e11763cd6..832cc74df 100644 --- a/resources/views/errors/403.blade.php +++ b/resources/views/errors/403.blade.php @@ -12,7 +12,7 @@ @php $landing_page = user() ? route(user()->landing_page) : route('login'); @endphp -  {{ trans('general.go_to', ['name' => trans_choice('general.dashboards', 1)]) }} +  {{ trans('general.go_to_dashboard') }} @endsection diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php index 0e9e5993c..83ff8789e 100644 --- a/resources/views/errors/404.blade.php +++ b/resources/views/errors/404.blade.php @@ -12,7 +12,7 @@ @php $landing_page = user() ? route(user()->landing_page) : route('login'); @endphp -  {{ trans('general.go_to', ['name' => trans_choice('general.dashboards', 1)]) }} +  {{ trans('general.go_to_dashboard') }} @endsection diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php index 6d8d08ebf..047a69f42 100644 --- a/resources/views/errors/500.blade.php +++ b/resources/views/errors/500.blade.php @@ -12,7 +12,7 @@ @php $landing_page = user() ? route(user()->landing_page) : route('login'); @endphp -  {{ trans('general.go_to', ['name' => trans_choice('general.dashboards', 1)]) }} +  {{ trans('general.go_to_dashboard') }} @endsection diff --git a/resources/views/wizard/finish/index.blade.php b/resources/views/wizard/finish/index.blade.php index 90beef77f..2baa55f5c 100644 --- a/resources/views/wizard/finish/index.blade.php +++ b/resources/views/wizard/finish/index.blade.php @@ -58,7 +58,7 @@