option('days'); $dryRun = (bool) $this->option('dry-run'); $users = User::onlyTrashed() ->where('is_system', false) ->whereNull('anonymized_at') ->where('deleted_at', '<=', now()->subDays($days)) ->get(); if ($users->isEmpty()) { $this->info('No users to anonymize.'); return self::SUCCESS; } foreach ($users as $user) { if ($dryRun) { $this->line(sprintf(' [dry-run] #%d %s', $user->id, $user->email)); continue; } $purge->execute($user); $this->line(sprintf(' ✓ anonymized user #%d', $user->id)); } $this->info(($dryRun ? '[dry-run] ' : '').'Processed users: '.$users->count()); return self::SUCCESS; } }