From bee80fcf8a42590deca8d74a28b66545add345c0 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 6 Aug 2024 12:16:06 -0700 Subject: [PATCH] Remove global scope when counting check outs --- app/Models/Component.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Models/Component.php b/app/Models/Component.php index 671b0101c4..536e06d0af 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -205,7 +205,11 @@ class Component extends SnipeModel public function numCheckedOut() { $checkedout = 0; - foreach ($this->assets as $checkout) { + + // In case there are elements checked out to assets that belong to a different company + // than this asset and full multiple company support is on we'll remove the global scope, + // so they are included in the count. + foreach ($this->assets()->withoutGlobalScope(new CompanyableScope)->get() as $checkout) { $checkedout += $checkout->pivot->assigned_qty; }