feat: implement soft deletes, mailbox reclaims, cooldowns, and auto-cleanup
This commit is contained in:
37
app/Console/Commands/CleanupExpiredMailboxes.php
Normal file
37
app/Console/Commands/CleanupExpiredMailboxes.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CleanupExpiredMailboxes extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mailboxes:cleanup';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Cleanup expired mailboxes and their associated data';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$mailboxes = \App\Models\Mailbox::where('expires_at', '<=', now())->get();
|
||||
$count = $mailboxes->count();
|
||||
|
||||
foreach ($mailboxes as $mailbox) {
|
||||
$mailbox->delete(); // Triggers soft-delete and the 'deleted' event listener
|
||||
}
|
||||
|
||||
$this->info("Cleaned up {$count} expired mailboxes.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user