Files
newznab-tmux/app/Jobs/PurgeDeletedAccounts.php
T
2026-02-26 14:26:07 +01:00

44 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class PurgeDeletedAccounts implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* Find users that were soft-deleted 6 months ago and permanently delete them.
*/
public function handle(): void
{
// Find users that were soft-deleted 6 months ago
User::onlyTrashed()
->where('deleted_at', '<', now()->subDays(config('nntmux.purge_inactive_users_days')))
->get()
->each(function ($user) {
$user->forceDelete(); // Permanently delete the user
});
}
}