where('enabled', true)->chunkById(100, function ($channels) use (&$deleted) { foreach ($channels as $channel) { $days = max(7, (int) data_get($channel->settings, 'retention_days', 90)); $deleted += UserNotification::where('tenant_id', $channel->tenant_id) ->where('created_at', '<', now()->subDays($days))->delete(); } }); NotificationWebhookLog::where('created_at', '<', now()->subDays(90))->delete(); $this->info("{$deleted} notifikasi lama dihapus."); return self::SUCCESS; } }