merge: integrate inventory threshold 20% fix

This commit is contained in:
sky121113 2026-05-16 20:08:20 +08:00
commit 5574f845ab

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')