Skip to content

Commit d4ba7ff

Browse files
committed
Use eachById when cleaning emails
1 parent 7d5da44 commit d4ba7ff

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Console/CleanEmails.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ public function handle()
3737

3838
$modelClass::where('created_at', '<', $cutOffDate)
3939
->select('id')
40-
->chunk(100, function ($models) use ($modelClass) {
41-
foreach ($models as $model) {
42-
$modelInstance = $modelClass::find($model->id);
43-
$modelInstance->delete();
44-
$this->amountDeleted++;
45-
}
40+
->eachById(function ($model) use ($modelClass) {
41+
$modelInstance = $modelClass::find($model->id);
42+
$modelInstance->delete();
43+
$this->amountDeleted++;
4644
});
4745

4846
$this->info("Deleted {$this->amountDeleted} record(s) from the Mailbox logs.");

0 commit comments

Comments
 (0)