<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Domain\Domain\Models\Domain;
use App\Domain\Ssl\Enums\SslStatus;
use App\Domain\Ssl\Models\SslCertificate;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<SslCertificate>
 */
class SslCertificateFactory extends Factory
{
    protected $model = SslCertificate::class;

    public function definition(): array
    {
        $domain = Domain::factory()->active()->create();

        return [
            'domain_id' => $domain->id,
            'issuer' => 'lets-encrypt',
            'challenge' => 'http-01',
            'common_name' => $domain->name,
            'alt_names' => ['www.'.$domain->name],
            'issued_at' => now()->subDays(30),
            'expires_at' => now()->addDays(60),
            'status' => SslStatus::Active,
            'auto_renew' => true,
        ];
    }
}
