<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Domain\Account\Models\Account;
use App\Domain\Email\Models\EmailAccount;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<EmailAccount>
 */
class EmailAccountFactory extends Factory
{
    protected $model = EmailAccount::class;

    public function definition(): array
    {
        $local = $this->faker->unique()->userName();
        $domain = $this->faker->domainName();

        return [
            'account_id' => Account::factory()->active(),
            'local' => $local,
            'domain' => $domain,
            'password_hash' => bcrypt('Password123!'),
            'quota_mb' => 1024,
            'usage_bytes' => 0,
            'status' => 'active',
            'auto_create_dirs' => true,
        ];
    }

    public function suspended(): static
    {
        return $this->state(['status' => 'suspended']);
    }
}
