This nasty little method gets the low inventory info for the alert dropdown.
203 $consumables = Consumable::with(
'users')->whereNotNull(
'min_amt')->get();
204 $accessories = Accessory::with(
'users')->whereNotNull(
'min_amt')->get();
205 $components = Component::with(
'assets')->whereNotNull(
'min_amt')->get();
207 $avail_consumables = 0;
208 $items_array = array();
211 foreach ($consumables as $consumable) {
212 $avail = $consumable->numRemaining();
213 if ($avail < ($consumable->min_amt) + 3) {
214 $percent = number_format((($consumable->numRemaining() / $consumable->qty) * 100), 0);
215 $items_array[$all_count][
'id'] = $consumable->id;
216 $items_array[$all_count][
'name'] = $consumable->name;
217 $items_array[$all_count][
'type'] =
'consumables';
218 $items_array[$all_count][
'percent'] = $percent;
219 $items_array[$all_count][
'remaining']=$consumable->numRemaining();
220 $items_array[$all_count][
'min_amt']=$consumable->min_amt;
227 foreach ($accessories as $accessory) {
228 $avail = $accessory->numRemaining();
229 if ($avail < ($accessory->min_amt) + 3) {
230 $percent = number_format((($accessory->numRemaining() / $accessory->qty) * 100), 0);
231 $items_array[$all_count][
'id'] = $accessory->id;
232 $items_array[$all_count][
'name'] = $accessory->name;
233 $items_array[$all_count][
'type'] =
'accessories';
234 $items_array[$all_count][
'percent'] = $percent;
235 $items_array[$all_count][
'remaining']=$accessory->numRemaining();
236 $items_array[$all_count][
'min_amt']=$accessory->min_amt;
242 foreach ($components as $component) {
243 $avail = $component->numRemaining();
244 if ($avail < ($component->min_amt) + 3) {
245 $percent = number_format((($component->numRemaining() / $component->total_qty) * 100), 0);
246 $items_array[$all_count][
'id'] = $component->id;
247 $items_array[$all_count][
'name'] = $component->name;
248 $items_array[$all_count][
'type'] =
'components';
249 $items_array[$all_count][
'percent'] = $percent;
250 $items_array[$all_count][
'remaining']=$component->numRemaining();
251 $items_array[$all_count][
'min_amt']=$component->min_amt;