<?php

namespace App\Domains\Domain\Jobs;

use App\Domains\Domain\Actions\VerifyDomain;
use App\Domains\Domain\Models\Domain;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;

class VerifyPendingDomainsJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable;

    public function handle(VerifyDomain $action): void
    {
        Domain::whereNull('verified_at')
            ->where('created_at', '>=', now()->subDays(30))
            ->each(fn (Domain $domain) => $action->handle($domain));
    }
}
