[PROMOTE] Dev to Demo: Updated low stock warning logic to 20% threshold

1. fix: update low stock warning threshold to 20% of max_stock
2. merge: integrate inventory threshold 20% fix
This commit is contained in:
sky121113 2026-05-16 20:08:37 +08:00
commit 8fa2421978

View File

@ -207,7 +207,8 @@ class RemoteController extends Controller
$machineQuery = Machine::withCount([
'slots as slots_count',
'slots as low_stock_count' => function ($query) {
$query->where('stock', '<=', 5);
$query->where('max_stock', '>', 0)
->whereRaw('stock <= (max_stock * 0.2)');
},
'slots as expiring_soon_count' => function ($query) {
$query->whereNotNull('expiry_date')