whereNotNull('custom_domain')->whereNotNull('domain_token'); if ($uuid = $this->option('instance')) { $query->where('uuid', $uuid); } $checked = 0; $withdrawn = 0; foreach ($query->cursor() as $instance) { $checked++; $present = $verifier->proofPresent($instance); if ($present) { $instance->forceFill([ 'domain_verified_at' => $instance->domain_verified_at ?? now(), 'domain_checked_at' => now(), 'domain_error' => null, 'domain_failures' => 0, ])->save(); continue; } $failures = $instance->domain_failures + 1; // Withdrawal clears verified_at, which is the single flag every // consumer reads. Nothing else is deleted: the domain and its token // stay on the row, so the customer sees what is wrong and can put // the record back rather than starting over. $withdraw = $instance->domain_verified_at !== null && $failures >= DomainVerifier::FAILURES_BEFORE_WITHDRAWAL; $instance->forceFill([ 'domain_checked_at' => now(), 'domain_error' => 'missing_txt', 'domain_failures' => $failures, 'domain_verified_at' => $withdraw ? null : $instance->domain_verified_at, ])->save(); if ($withdraw) { $withdrawn++; $this->warn("Withdrew {$instance->custom_domain}: proof missing on {$failures} consecutive checks."); } } $this->info("Checked {$checked} domain(s), withdrew {$withdrawn}."); return self::SUCCESS; } }