File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff 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 )->with ( ' assets ' )-> get ();
751+ $ asset_models = AssetModel::where ('min_amt ' , '> ' , 0 )->get ();
752752 $ licenses = License::where ('min_amt ' , '> ' , 0 )->get ();
753753
754754 $ items_array = [];
@@ -811,13 +811,11 @@ public static function checkLowInventory()
811811 }
812812 }
813813
814+ foreach ($ asset_models as $ asset_model ){
814815
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 ();
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 ();
821819
822820 if ($ avail < ($ asset_model ->min_amt ) + $ alert_threshold ) {
823821 if ($ avail > 0 ) {
You can’t perform that action at this time.
0 commit comments