<?php

namespace Database\Factories;

use App\Enums\FormType;
use App\Models\Document;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * @extends Factory<Document>
 */
class DocumentFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $name = fake()->unique()->words(3, true);

        return [
            'name' => $name,
            'slug' => Str::slug($name),
            'description' => fake()->sentence(),
            'form_type' => fake()->randomElement(FormType::cases()),
            'content' => '<h1>Document Template</h1><p>Applicant: {{applicant.name}}</p>',
            'version' => 1,
        ];
    }

    /**
     * Set the document to adoption form type.
     */
    public function adoption(): static
    {
        return $this->state(fn (array $attributes) => [
            'form_type' => FormType::Adoption,
        ]);
    }

    /**
     * Set the document to fostering form type.
     */
    public function fostering(): static
    {
        return $this->state(fn (array $attributes) => [
            'form_type' => FormType::Fostering,
        ]);
    }

    /**
     * Set the document to assistance form type.
     */
    public function assistance(): static
    {
        return $this->state(fn (array $attributes) => [
            'form_type' => FormType::Assistance,
        ]);
    }
}
