<?php

namespace Database\Factories;

use App\Models\Release;
use App\Models\ReleaseReport;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<ReleaseReport>
 */
class ReleaseReportFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var class-string<ReleaseReport>
     */
    protected $model = ReleaseReport::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $reasons = array_keys(ReleaseReport::REASONS);

        return [
            'releases_id' => Release::factory(),
            'users_id' => User::factory(),
            'reason' => fake()->randomElement($reasons),
            'description' => fake()->optional()->sentence(),
            'status' => 'pending',
        ];
    }

    /**
     * Indicate that the report is pending.
     */
    public function pending(): static
    {
        return $this->state(fn (array $attributes) => [
            'status' => 'pending',
        ]);
    }

    /**
     * Indicate that the report has been reviewed.
     */
    public function reviewed(): static
    {
        return $this->state(fn (array $attributes) => [
            'status' => 'reviewed',
            'reviewed_by' => User::factory(),
            'reviewed_at' => now(),
        ]);
    }

    /**
     * Indicate that the report has been resolved.
     */
    public function resolved(): static
    {
        return $this->state(fn (array $attributes) => [
            'status' => 'resolved',
            'reviewed_by' => User::factory(),
            'reviewed_at' => now(),
        ]);
    }

    /**
     * Indicate that the report has been dismissed.
     */
    public function dismissed(): static
    {
        return $this->state(fn (array $attributes) => [
            'status' => 'dismissed',
            'reviewed_by' => User::factory(),
            'reviewed_at' => now(),
        ]);
    }
}
