Skip to content

A free open source IT asset/license management system

Make locations deletable for non Superuser-Accounts with FullMultipleCompanySupport

Tobias Regnery1a908e361e19
diff --git a/app/Models/Company.php b/app/Models/Company.php
index 04f138ccd0..529a59a0bc 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -125,6 +125,11 @@ final class Company extends SnipeModel
return false;
} elseif (!static::isFullMultipleCompanySupportEnabled()) {
return true;
+ } elseif (!$companyable instanceof Company && !\Schema::hasColumn($companyable->getModel()->getTable(), 'company_id')) {
+ // This is primary for the gate:allows-check in location->isDeletable()
+ // Locations don't have a company_id so without this it isn't possible to delete locations with FullMultipleCompanySupport enabled
+ // because this function is called by SnipePermissionsPolicy->before()
+ return true;
} else {
if (Auth::user()) {
$current_user_company_id = Auth::user()->company_id;