Remove global scope when counting check outs

This commit is contained in:
Marcus Moore 2024-08-06 12:16:06 -07:00
parent 0aff35b622
commit bee80fcf8a
No known key found for this signature in database

View file

@ -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;
}