Skip to content

Commit cdf4fcd

Browse files
authored
Merge pull request #24 from webfox/feature_delete-individual-models
Change CleanEmails command to delete individual models
2 parents d0d300b + 85e36c4 commit cdf4fcd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Console/CleanEmails.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ public function handle()
2020

2121
$cutOffDate = Carbon::now()->subDay($maxAgeInDays)->format('Y-m-d H:i:s');
2222

23-
$amountDeleted = InboundEmail::where('created_at', '<', $cutOffDate)->delete();
23+
/** @var InboundEmail $modelClass */
24+
$modelClass = config('mailbox.model');
25+
26+
$models = $modelClass::where('created_at', '<', $cutOffDate)->get();
27+
28+
$models->each->delete();
29+
30+
$amountDeleted = $models->count();
2431

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

0 commit comments

Comments
 (0)