From 5c11147e95efce7eeb21e504de4536c1bcca4d5c Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Sat, 11 Apr 2026 08:00:00 +0200 Subject: [PATCH] feat(settings): allow Danger Zone for any owner regardless of company count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes three layered gates that kept the Danger Zone completely hidden unless the current user had more than one company: 1. SettingsLayoutView's showDangerZone computed no longer checks companies.length > 1 — just is_owner. 2. DangerZoneView drops the v-if that wrapped the delete button with the same check. 3. Admin\\CompaniesController::destroy() drops the companies_count <= 1 early-return that was enforcing the rule server-side (translation key You_cannot_delete_all_companies was inline in the controller, not in lang files or tests, so nothing else needs cleanup). The reasoning behind the old gate was that a user with zero companies would be stranded. That's a misread of how the app degrades: /admin/no-company already exists as a graceful fallback view, and the user can create a fresh company from there to recover. Hiding the entire delete flow just to avoid that fallback UX was overkill — the name-confirmation modal already prevents accidental deletion. --- app/Http/Controllers/Admin/CompaniesController.php | 4 ---- .../features/company/settings/views/DangerZoneView.vue | 4 +--- .../features/company/settings/views/SettingsLayoutView.vue | 7 +------ 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Admin/CompaniesController.php b/app/Http/Controllers/Admin/CompaniesController.php index 8bb11190..aa05fe5f 100644 --- a/app/Http/Controllers/Admin/CompaniesController.php +++ b/app/Http/Controllers/Admin/CompaniesController.php @@ -97,10 +97,6 @@ class CompaniesController extends Controller return respondJson('company_name_must_match_with_given_name', 'Company name must match with given name'); } - if ($user->loadCount('companies')->companies_count <= 1) { - return respondJson('You_cannot_delete_all_companies', 'You cannot delete all companies'); - } - $this->companyService->delete($company, $user); return response()->json([ diff --git a/resources/scripts/features/company/settings/views/DangerZoneView.vue b/resources/scripts/features/company/settings/views/DangerZoneView.vue index f3e69b64..bc3e503b 100644 --- a/resources/scripts/features/company/settings/views/DangerZoneView.vue +++ b/resources/scripts/features/company/settings/views/DangerZoneView.vue @@ -1,11 +1,9 @@