Skip to content

A free open source IT asset/license management system

Check for null company ID

snipe279e6c7e4f4a
diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php
index bc5465e4be..1fdd0a0cc3 100644
--- a/app/Http/Controllers/Assets/AssetCheckoutController.php
+++ b/app/Http/Controllers/Assets/AssetCheckoutController.php
@@ -91,7 +91,8 @@ class AssetCheckoutController extends Controller
$settings = \App\Models\Setting::getSettings();
- if ($settings->full_multiple_companies_support){
+ // We have to check whether $target->company_id is null here since locations don't have a company yet
+ if (($settings->full_multiple_companies_support) && ((!is_null($target->company_id)) && (!is_null($asset->company_id)))) {
if ($target->company_id != $asset->company_id){
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company'));
}