<?php

namespace Database\Factories;

use App\Enums\TimelineStatus;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Timeline>
 */
class TimelineFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'case_name' => fake()->sentence(3),
            'case_reference' => fake()->boolean(70) ? fake()->unique()->regexify('[A-Z]{2}-[0-9]{4}-[0-9]{3}') : null,
            'status' => TimelineStatus::Active,
        ];
    }

    /**
     * Create an active timeline.
     */
    public function active(): static
    {
        return $this->state(fn (array $attributes) => [
            'status' => TimelineStatus::Active,
        ]);
    }

    /**
     * Create an archived timeline.
     */
    public function archived(): static
    {
        return $this->state(fn (array $attributes) => [
            'status' => TimelineStatus::Archived,
        ]);
    }

    /**
     * Create a timeline with a case reference.
     */
    public function withReference(): static
    {
        return $this->state(fn (array $attributes) => [
            'case_reference' => fake()->unique()->regexify('[A-Z]{2}-[0-9]{4}-[0-9]{3}'),
        ]);
    }
}
