Merge pull request #9876 from Toreg87/fixes/locations-deletable

Fixed #9875: Make locations deletable for non Superuser-Accounts with FullMultipleCompanySupport
This commit is contained in:
snipe 2022-12-14 17:46:53 -08:00 committed by GitHub
commit 418ddcfac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -127,6 +127,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;