Skip to content

Commit e69ad08

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

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Console/CleanEmails.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ 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(count: 100, callback: function ($model) {
41+
$model->delete();
42+
$this->amountDeleted++;
4643
});
4744

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

0 commit comments

Comments
 (0)