deleteBatchSize); $model = $query->getModel(); $keyName = $model->getKeyName(); $total = 0; while (true) { // audit:allow query-repeated-execution 배치 삭제는 같은 술어를 의도적으로 반복 평가한다 — 매 회차의 모집단이 직전 삭제로 줄어든다 $keys = (clone $query)->orderBy($keyName)->limit($batchSize)->pluck($keyName); if ($keys->isEmpty()) { return $total; } $total += $model->newQuery()->whereIn($keyName, $keys)->delete(); // 마지막 배치 — 더 조회할 것이 없다 if ($keys->count() < $batchSize) { return $total; } } } }