Skip to content

Commit dafc6c5

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents c790147 + 6901dec commit dafc6c5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/Helpers/Helper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public static function checkLowInventory()
748748
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
749749
$accessories = Accessory::withCount('checkouts as checkouts_count')->whereNotNull('min_amt')->get();
750750
$components = Component::whereNotNull('min_amt')->get();
751-
$asset_models = AssetModel::where('min_amt', '>', 0)->get();
751+
$asset_models = AssetModel::where('min_amt', '>', 0)->with('assets')->get();
752752
$licenses = License::where('min_amt', '>', 0)->get();
753753

754754
$items_array = [];
@@ -811,11 +811,13 @@ public static function checkLowInventory()
811811
}
812812
}
813813

814-
foreach ($asset_models as $asset_model){
815814

816-
$asset = new Asset();
817-
$total_owned = $asset->where('model_id', '=', $asset_model->id)->count();
818-
$avail = $asset->where('model_id', '=', $asset_model->id)->whereNull('assigned_to')->count();
815+
816+
817+
foreach ($asset_models as $asset_model) {
818+
819+
$total_owned = $asset_model->assets->count();
820+
$avail = $asset_model->assets->whereNull('assets.assigned_to')->count();
819821

820822
if ($avail < ($asset_model->min_amt) + $alert_threshold) {
821823
if ($avail > 0) {

0 commit comments

Comments
 (0)