<?php

namespace Database\Factories;

use App\Enums\HarimStates;
use App\Models\HarimAction;
use App\Models\HarimState;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\HarimHistory>
 */
class HarimHistoryFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'previous_state_id' => HarimState::factory(),
            'previous_state_name' => function (array $attributes) {
                return HarimStates::query()->find($attributes['state_id'])->name;
            },
            'current_state_id' => HarimState::factory(),
            'current_state_name' => function (array $attributes) {
                return HarimState::query()->find($attributes['state_id'])->name;
            },
            'action_id' => HarimAction::factory(),
            'action_name' => function (array $attributes) {
                return HarimAction::query()->find($attributes['state_id'])->name;
            },
            'expert_id' => User::factory(),
            'expert_description' => $this->fake()->text,
            'previous_data' => json_encode(['fake']),
        ];
    }
}
